Good afternoon, I need to convert a UUID to sha256 and later to md5, in java it worked, but if I do it by pgadmin(postgres) 1 character is different
in java
public class outro {
public static void main(String[] args) {
String prontuarioBaseUUID = "a1d347fc-094f-49de-91b9-f2765c58b94d";
System.out.println(uuidSha2Encrypt(prontuarioBaseUUID));
}
public static String uuidSha2Encrypt(String uuid) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(uuid.getBytes());
return UUID.nameUUIDFromBytes(md.digest()).toString();
} catch (NoSuchAlgorithmException ns) {
throw new RuntimeException("Algoritmo SHA-256 não disponível", ns);
}
}
result d5fabb45-dbd1-399b-a6c1-515367b8a2d4
in pgadmin postgres
select uuid_in(md5(digest('a1d347fc-094f-49de-91b9-f2765c58b94d', 'sha256'))::cstring) from tb_paciente
result d5fabb45-dbd1-b99b-a6c1-515367b8a2d4
what is problem? thxx
- d5fabb45-dbd1-399b-a6c1-515367b8a2d4
- d5fabb45-dbd1-b99b-a6c1-515367b8a2d4