0

I have SHA2-512 password encryption set up on my application. While creating users, the password is created using the below method:

DECLARE @salt UNIQUEIDENTIFIER=NEWID(); select
HASHBYTES('SHA2_512','password'+CAST(@salt AS NVARCHAR(36)))

I am now trying to implement this in Java. I see the MessageDigest helps creating SHA-512 but SHA2-512 throws NoSuchAlgorithmException exception.

Any suggestions with appropriate methods of getting this on Java side will be helpful.

Reema
  • 587
  • 3
  • 12
  • 37
  • 1
    Are you saying that you copy-pasted a solution from [a question like this](https://stackoverflow.com/questions/33085493/how-to-hash-a-password-with-sha-512-in-java), ran it, and found that SHA-512 is not available? – that other guy May 13 '20 at 19:18
  • 1
    I didn't copy paste a solution, but I did copy-paste a question with a different algorithm. Anything wrong in doing that when it just means what I want it to mean? – Reema May 14 '20 at 08:43
  • 1
    Oh, I see what you mean now. You can just use `SHA-512`, since this is the canonical name for the same algorithm. SHA-512 is from the SHA2 series of hashes, and there's no 512 bit version of SHA1. (PS: this is not a secure way to store passwords) – that other guy May 14 '20 at 15:26

0 Answers0