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));}



-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/f4f08b89-d04e-498d-b3a0-c8a1855b250f%40googlegroups.com.

Reply via email to