crypt函数的不同输出

时间:2018-04-27 01:23:13

标签: c output crypt

与C中的crypt函数传递完全相同的密钥有两种不同。

文件#1:crack.c, 输入crack.c

string HashedPassword;
string Hash = argv[1];
char Salt[2];
Salt[0] = Hash[0];
Salt[1] = Hash[1];
char Key1 = 'a';

int Counter = 1;
    do
    {
        HashedPassword = crypt(&Key1, Salt); `Creates Hashed password from Key1 & stores in Variable Hashed password`
        printf("key1 value is :%c & hashed Password is : %s\n", Key1, HashedPassword);
        if(strcmp(Hash, HashedPassword) == 0) `Compares if Hash entered by user matches the Hashed password created from Key1`
        {
            printf("%c\n", Key1); `prints the value stored in key1 if the hashed password made from Key1 matches the hash entered by user`
            return 0;
        }
        Key1++;
        Counter++;
    }
    while( Counter <= 26 );

 Ouput from crack.c
 ~/workspace/pset2/crack/ $ ./crack 50OqznXGVcOJU
 key1 value is :a & hashed Password is : 506RGmWzsA7ws
 key1 value is :b & hashed Password is : 50YG8tFx67moY
 key1 value is :c & hashed Password is : 50Ebw7/ICYLEY
 ...
 ...
 ...

======

文件#2:test2.c, 在test2.c中输入

int main()
{
char Key1 = 'a';
string HashedPassword;

HashedPassword = crypt(&Key1, "50"); `Creates Hashed password from Key1 & stores in Variable Hashed password`

printf("key1 value is :%c & hashed Password is : %s\n", Key1,  HashedPassword); `Prints the value of Key1 & hash created by crypt function`

printf("%s", HashedPassword);

}

/ *忽略斜杠中的行asdasad,kfanlkfdsnjn,m kdsafnn nmksdfl sdlkasdjaslkdhaslkdjahskj * /

Ouput from test2.c `Output for test.c`
~/workspace/ $ ./test2
key1 value is :a & hashed Password is : 50OqznXGVcOJU 
50OqznXGVcOJU~/workspace/ $ 

0 个答案:

没有答案