a strong function for hash strings and restore it

前端 未结 3 1042
难免孤独
难免孤独 2021-01-24 12:34

I\'m looking for a strong hash function (algorithm) to hash my codes. i want to restore hashed string to original string. (can i restore sha to ori

3条回答
  •  后悔当初
    2021-01-24 13:12

    You can't restore the original data from a hash as it is not reversible by design. An usual explanation is the Pigeonhole Principle - most hashes are about 128-256 bits, so 16-32 bytes in size. As soon as your string is longer (and even before this) than this, there will be two strings that have the same hash. This is called a collision.

    Also note that strings shorter than 16-32 bytes can often be reversed, although you shouldn't rely on this as there can be collisions, too. For example, hash some string like test and search for the hash on Google.

    Nevertheless, even test and some other short word could have the same hash, so you'll never be 100% sure you've got the right string.

提交回复
热议问题