D
D
Dima Bck2020-12-03 17:11:02
C++ / C#
Dima Bck, 2020-12-03 17:11:02

Why don't sha1 results match?

Here is a small part of the c++ code:

byte pas[] = "YYYYYYYYYY";
  byte hash1[] = "XXXXXXXXXXXXXXXXXXXX";
  byte hash2[] = "XXXXXXXXXXXXXXXXXXXX";
  SHA1(pas, 10, hash1);
  for (int i = 0; i < 20; i++)
    printf("%02x ", hash1[i]);
  cout << endl;
  SHA1(hash1, 20, hash2);
  for (int i = 0; i < 20; i++)
    printf("%02x ", hash2[i]);
  cout << endl;

After the first calculation, sha1 outputs (c7 6f 17 f1 91 05 de 28 39 da b1 ea a2 a2 98 56 3d 67 df 21), just like the online service, but after the 2nd calculation it outputs (8b b9 86 c5 25 93 23 91 4d 0b 68 d0 74 84 30 bf 0c c3 1a 63), but in the online service (ed bc 29 67 9e b1 fd 0c 08 9b 7b d6 fa 40 6f 85 0f 08 68 a0) why so?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
jcmvbkbc, 2020-12-03
@provokator2020

why is that?

I suspect that because the result of the SHA1 function is binary and not string. In your program, you hash the bytes of the result in the second step, and insert their string hexadecimal representation into the site.

D
Daniil Naumovets, 2020-12-03
@nikkyhud

Because the same characters correspond to several "codes" that are selected randomly.
For example n=['01','02','03'], p=['10','20',30'], u=['04','05'], a=['40' ,'50'], e = ['06','07','08'], m = ['60',70',80']
and then the word "hello" can be encoded in 324 ways (on n - 3 ways, for p - 3 ways, for and - 2 ways, for c - 2 ways, for y - 3 ways and for t - 3 ways, i.e. 3 * 3 * 2 * 2 * 3 * 3 = 324, simple combinatorics). This is necessary to complicate decryption.
Here are 2 examples of how you can encrypt the word "hello" using my "cipher":

S
Sergey Pankov, 2020-12-03
@trapwalker

The first thing to check is whether the service cuts to length. Make x's the same length as y's and check again

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question