/ Published in: C
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
//
// Author : Keiran "Affix" Smith <Affix_at_Affix_dot_me>
// Website: http://keiran-smith.net
// Description :
// Generate a Simple Random Password
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#include <stdio.h>
#include <stdlib.h>
#ifdef DEVRANDOM
#include <fcntl.h>
#endif
int max;
char *charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
void seed()
{
int i, j;
#ifdef DEVRANDOM
int fd;
#endif
i = getpid();
#ifdef DEVRANDOM
fd = open(DEVRANDOM, O_RDONLY, 0);
if (fd == -1) {
}
read(fd, &i, sizeof(charset));
j = j ^ i;
close(fd);
#endif
}
char *shuffle(char *v, size_t n)
{
int i, j;
char *s;
for (i=0; i < n; i++) {
do
while (j < i);
s = v;
v = v;
v = s;
}
return v;
}
int main(int argc, char *argv[])
{
if(argv[1])
else
max = 8;
seed();
int i = 0;
while(i < max)
{
charset = shuffle(charset, sizeof(charset));
char pchar = charset[rnd_num];
i++;
}
return 0;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                