How can we convert from String to Hex in java
This code is part of AES encryption algorithm, I have this method that return the encrypted value as: String I need it to return the result as Hex instead .
public static String encrypt(String Data) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
Key key = generateKey();
Cipher c = Cipher.getInstance(ALGO);
c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes());
String encryptedValue = new String( Base64.getEncoder().encode(encVal) ) ;
return encryptedValue;
}