3

Please help me the code (Java) to encrypt and decrypt ( will be better if using private key) with SHA256.

4 Answers 4

11

The Secure Hash Algorithm family of functions are one-way functions. You can use the functions to get a cryptographic hash from any given input, but it is impossible to reverse the function and arrive at the input from any given output hash.

Sign up to request clarification or add additional context in comments.

Comments

8

I think you're confused about what SHA is. SHA is a Cryptographic Hash Function, not an encryption algorithm. You can't reverse the operation to determine the message that was used to generate a particular hash.

Comments

6

There have actually been several techniques proposed for turning hash functions into block ciphers that can encrypt and decrypt - for example Peter Gutmann's "Message Digest Cipher".

This paper has some cryptanalysis of some of these techniques.

But you really don't want to do this - you are far better off using a well-studied block cipher, like AES.

Comments

4

SHA-256 is a one way algorithm, it cannot be decrypted!

1 Comment

How to this website work ?. md5decrypt.net/en/Sha256/#answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.