I am encrypting an email and saving it in the database, how do I decrypt the same email that was encrypted.
Follow the code I used to encrypt.
public String getEmailCriptografado(String email){
email = email.toLowerCase();
email = Normalizer.normalize(email, Normalizer.Form.NFD);
Pattern pattern = Pattern.compile("\p{InCombiningDiacriticalMarks}+");
pattern.matcher(email).replaceAll("");
String emailCritptografado = "";
try {
MessageDigest algoritmo = MessageDigest.getInstance("SHA-256");
try {
byte messageDigest[] = algoritmo.digest((email)
.getBytes("UTF-8"));
StringBuilder hexString = new StringBuilder();
for (byte b : messageDigest) {
hexString.append(String.format("%02X", 0xFF & b));
}
emailCritptografado = hexString.toString();
System.out.println(emailCritptografado);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return emailCriptografado;
}
Is there any way to decrypt in this way?