上传文件至 ''
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define BUFFER_SIZ 270
|
#define BUFFER_SIZ 8192
|
||||||
|
|
||||||
|
|
||||||
char pool[] = {
|
char pool[] = {
|
||||||
@@ -18,17 +18,10 @@ char pool[] = {
|
|||||||
'Y', 'Z', '!', '@', '#', '$', '%', '^', '&', '*',
|
'Y', 'Z', '!', '@', '#', '$', '%', '^', '&', '*',
|
||||||
'[', ']', '\\', '|', ';', '\'', ',', '.', '/', '{', '}', ':', '"', '<', '>', '?'
|
'[', ']', '\\', '|', ';', '\'', ',', '.', '/', '{', '}', ':', '"', '<', '>', '?'
|
||||||
|
|
||||||
|
};
|
||||||
}; //随机池
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// srand(time(0));
|
|
||||||
/*
|
|
||||||
使用 time(0) 做种子,在一秒之内种子是不会变的
|
|
||||||
通过使用微妙,来增加随机数的随机性
|
|
||||||
*/
|
|
||||||
|
|
||||||
int PASSWD_LEN = 16;
|
int PASSWD_LEN = 16;
|
||||||
struct timeval tpstart;
|
struct timeval tpstart;
|
||||||
char password[BUFFER_SIZ];
|
char password[BUFFER_SIZ];
|
||||||
@@ -39,11 +32,17 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
PASSWD_LEN = atoi(argv[1]);
|
PASSWD_LEN = atoi(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PASSWD_LEN >= BUFFER_SIZ)
|
||||||
|
{
|
||||||
|
printf("Password too long!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
memset(password, 0, BUFFER_SIZ);
|
memset(password, 0, BUFFER_SIZ);
|
||||||
gettimeofday(&tpstart, NULL);
|
gettimeofday(&tpstart, NULL);
|
||||||
srand(tpstart.tv_usec);
|
srand(tpstart.tv_usec);
|
||||||
|
|
||||||
|
|
||||||
while (i != PASSWD_LEN) {
|
while (i != PASSWD_LEN) {
|
||||||
password[i++] = pool[rand() % sizeof(pool)];
|
password[i++] = pool[rand() % sizeof(pool)];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user