другой вывод из функции crypt - PullRequest
0 голосов
/ 27 апреля 2018

Получение двух отличных от точно таких же ключей, переданных в функцию crypt в C.

Файл № 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/ $ 
...