I actually have a problem with hashing a password
and trying to convert in string to put it in a database.
Currently I have this code
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(motsDePasse.getBytes(StandardCharsets.UTF_8));
String fileString = Base64.getEncoder().encodeToString(hash);
The deal is that it does not give me the good hash. Let's say I try to hash "12345
". It should give me 5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5
.
But it actually return WZRHGrsBESr8wYFZ9sx0tPURuZgG2lmzyvWpwXPKz8U=