Reputation: 218
I have my base64:
String myBase64 ="MSBtZV9yYW5nZT0xNiBjaHJvbWFfbWU9MSB0cmVsbGlzPTEgOHg4ZGN0PTEgY3FtPTAgZGV";
How convert this base64 String to sha256?
Upvotes: 0
Views: 2536
Reputation: 3697
Sha-256 is a hashing algorithm. Use following to create a hash of your base 64 string:
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] myHashBytes = digest.digest(myBase64.getBytes(StandardCharsets.UTF_8));
You can again base64 encode the hash bytes to get a hash string:
String myHash = Base64.getEncoder().encodeToString(myHashBytes);
Upvotes: 3