-
Linux Encryption
Code:
/*
* Encrypt
* encrypt.c
* compile on linux; use:
* gcc -o encrypt -lcrypt encrypt.c
* (C) Lucas Campbell 2001-2002
*/
#include <stdio.h>
int main(int argc, char* argv[])
{
if(argv[1] != NULL) {
printf("%s is encrypted using md5 as:\n",argv[1]);
printf("%s\n",crypt(argv[1],"$1$kL10as");
}
else {
ptintf("Need to add the string to be encrypted\n");
printf("Example: encrypt [text here]\n");
}
return 0;
}
// See top for details
now I am wondering how I can make a random salt that is 9 characters long but the first 3 are "$1$" because that initiates the md5 encryption algorithm.
Any help will be appreciated
The encryption program is mine and feel free to use it and distribute it as long as it contains the above information about compilation, copyright and the author.
-
Good thing you have that copyright notice there. You never know when some unscrupulous hacker is going to steal your code and make millions.
-
> now I am wondering how I can make a random salt that is 9
> characters long but
Here's a thought!
srand( time( 0 ) );
sprintf( buf "$s$%06d", rand()%1000000 );
Quzah.
-
Thanks, but that didn't really work.
What I want to do is place $1$letter in an array of nine
like:
Code:
[$][1][$][r][r][r][r][r][r]
where each r is replaced with a random character
problem is assigning more than one random integer!
-
Yawn.
#define R ((rand()%127)+1)
sprinf( buf, "$s$%c%c%c%c%c%c",R,R,R,R,R,R );
Or, if they have to be printable character:
int R(void){int c=-1; while(!isprint(c))c=rand()%256;return c;}
sprinf( buf, "$s$%c%c%c%c%c%c",R(),R(),R(),R(),R(),R() );
Wheee...
Quzah.