Do you know how to decipher the hash created by sha-256?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ke1_4519501
Level 1
Level 1

I have used the Cy_Crypto_Sha_Run () function to calculate the hash, but I have not found a way to reverse it or decrypt it, any ideas?

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Please note that SHA is a one-way cryptographic hash function and not a cipher. It produces a fixed length string (Hm) for the given input message (m). So, given Hm, it is not possible to get back m.

A typical use case is a password mechanism where based on the user password a fixed length hash gets created and gets stored in memory. Only when the right password is entered, you get the right hash which can be compared with the hash in memory to grant access.

Due to pre-image resistance, second pre-image resistance and collision resistance characteristics of SHA, it is mostly impossible to have another password which produces the same hash value.

If you need access to the original data I suggest you use an algorithm like AES. In the API Cy_Crypto_Aes_Ecb_Run(), it takes the first parameter as cy_en_crypto_dir_mode_t which can be used to specify if you want to encrypt or decrypt. Please refer to the PDL documentation for more information.

Hope this helps!

Regards,
Dheeraj

View solution in original post

0 Likes
3 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Please note that SHA is a one-way cryptographic hash function and not a cipher. It produces a fixed length string (Hm) for the given input message (m). So, given Hm, it is not possible to get back m.

A typical use case is a password mechanism where based on the user password a fixed length hash gets created and gets stored in memory. Only when the right password is entered, you get the right hash which can be compared with the hash in memory to grant access.

Due to pre-image resistance, second pre-image resistance and collision resistance characteristics of SHA, it is mostly impossible to have another password which produces the same hash value.

If you need access to the original data I suggest you use an algorithm like AES. In the API Cy_Crypto_Aes_Ecb_Run(), it takes the first parameter as cy_en_crypto_dir_mode_t which can be used to specify if you want to encrypt or decrypt. Please refer to the PDL documentation for more information.

Hope this helps!

Regards,
Dheeraj

0 Likes

Hi, what happens is that I want to create a digital signature with sha-256, so there must be a way to know the message after deciphering the signature, do you know if this can be done in psoc?

0 Likes

As mentioned previously SHA is not an encryption scheme. It is a keyed hashing algorithm which can be used to compare digital signatures when the input message is the same.

Message m1 ----> SHA ----> Digital Signature/HashValue (H1)

Message m2 ----> SHA ----> Digital Signature/HashValue (H2)

If and only if m1 = m2, then H1 = H2.

To encrypt the message and then decrypt it to get original message back, you need to use an encryption scheme like AES.

Regards,

Dheeraj

0 Likes