Im trying to convert this code to CN1, is there any equivalent to Cipher and MessageDigest classes?
public static byte[] decrypt(bytes[] key, byte[] bytesToDecrypt) {
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
int blockSize = cipher.getBlockSize();
byte[] iv = Arrays.copyOfRange(bytesToDecrypt, 0, blockSize);
byte[] encryptedData = Arrays.copyOfRange(bytesToDecrypt, blockSize, bytesToDecrypt.length);
IvParameterSpec ivspec = new IvParameterSpec(iv);
SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivspec);
return cipher.doFinal(encryptedData);
} catch (Exception e) {
Log.e(TAG, "Error while decrypting: " + e.toString());
}
return null;
}public byte[] sha256Hash(String inputCode) {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
return digest.digest(inputCode.getBytes(StandardCharsets.UTF_8));
}