比如说我的输出是:thwhglHDGQYE836
有没有办法把它作为输出混淆?如果有办法,一些建议会很好,谢谢:)。
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void) {
int i;
char c;
srand(time(NULL));
printf("Your Random Password is: ");
for (i = 0; i < 6; ++i) {
c = 'a' + rand() % ('z' - 'a' + 1);
printf("%c", c);
}
for (i = 0; i < 6; ++i) {
c = 'A' + rand() % ('Z' - 'A' + 1);
printf("%c", c);
}
for (i = 0; i < 3; ++i) {
c = '1' + rand() % ('1' - '9' + 1);
printf("%c", c);
}
printf("\n\n");
system("pause");
}
答案 0 :(得分:1)
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void) {
char password[6 + 6 + 3 + 1];
int i, j=0, len=sizeof(password)-1;
srand(time(NULL));
printf("Your Random Password is: ");
for (i = 0; i < 6; ++i)
password[j++] = 'a' + rand() % ('z' - 'a' + 1);
for (i = 0; i < 6; ++i)
password[j++] = 'A' + rand() % ('Z' - 'A' + 1);
for (i = 0; i < 3; ++i)
password[j++] = '1' + rand() % ('1' - '9' + 1);
password[j] = '\0';
for(i = 0; i < sizeof(password)-1; ++i)
{
char c = password[i];
j = rand() % len;
password[i] = password[j];
password[j] = c;
}
printf("%s\n\n", password);
system("pause");
}