How to convert base64 string to sha256?

3079 views java
1

I have my base64:

 String myBase64 ="MSBtZV9yYW5nZT0xNiBjaHJvbWFfbWU9MSB0cmVsbGlzPTEgOHg4ZGN0PTEgY3FtPTAgZGV";

How convert this base64 String to sha256?

answered question

What have you tried? Post it and people may be able to help

What do you mean by "convert … to sha256"? SHA256 is a digest, not a format.

1 Answer

0

Sha-256 is a hashing algorithm. Use following to create a hash of your base 64 string:

MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] myHash = digest.digest(myBase64.getBytes(StandardCharsets.UTF_8));

posted this

Have an answer?

JD

Please login first before posting an answer.