#include <crypt.h>#include <stdlib.h>#include <time.h>#include <unistd.h>#include <string>Go to the source code of this file.
Functions | |
| char | getsaltchar () |
| int | main (int argc, char *argv[]) |
|
|
Definition at line 10 of file crypt.cc. Referenced by main().
00011 {
00012 int r = (int) (64.0 * rand() / (RAND_MAX + 1.0));
00013 if (r < 26)
00014 return 'a' + r;
00015 r -= 26;
00016 if (r < 26)
00017 return 'A' + r;
00018 r -= 26;
00019 if (r < 10)
00020 return '0' + r;
00021 if (r < 1)
00022 return '.';
00023 else
00024 return '/';
00025 }
|
|
||||||||||||
|
Definition at line 27 of file crypt.cc. References getsaltchar().
00028 {
00029 char salt[2];
00030 int i;
00031
00032 if (argc != 2 || string(argv[1]) == "-?") {
00033 cerr << "Usage: " << argv[0] << " passwd" << endl;
00034 exit(1);
00035 }
00036
00037 srand(time(NULL));
00038 salt[0] = getsaltchar();
00039 salt[1] = getsaltchar();
00040
00041 cout << "crypt: " << crypt(argv[1], salt) << endl;
00042 }
|
1.3.6-20040222