Check if string xxx bit is hashed

How to check if a string has been tagged before certain bits? I want to unit test my method (which uses SHA512), I want to write a test to check if this string was returned, hashed at 512 bits.

+4
source share
3 answers

You cannot determine if a string is encrypted only by the string itself. You can enter data similar to the result of your SHA512 hash function, but without hashing.

If you know that it is hashed and you want to know if SHA512 was used, the only thing you can check is that the string is 512 bits long, but that will not tell you for sure if it is SHA512.

+2
source

If this is a one-way hash (you do not state that it is, but that means you use SHA512), then it cannot be decrypted. Indeed, the only way to verify this is:

  • Take a known input (i.e. a known plaintext string).
  • Calculate, in other words, that you trust what the expected encryption output should be.
  • Make sure your program or routine produces this output for this line.

Repeat with different inputs until you are satisfied.

+2
source

Repeat after me: Hashing is not encryption. The input to your hash algorithm is lost and cannot be restored.

SHA-512 has a 512-bit output , so one of you represents 512 bits and says that the SHA-512 algorithm output may be correct. As far as I know, the SHA algorithm does not have an easily identifiable template, so they can simply present you 512 bits of pure random noise.

Can you explain why you want to define the algorithm used to generate a specific hash?

+1
source

Source: https://habr.com/ru/post/1335749/


All Articles