leocavalcante / encrypt

🔒 A set of high-level APIs over PointyCastle for two-way cryptography.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output double in size, AES in CTR

GideonKock opened this issue · comments

As the code describes, I have an input of 18 characters, but the result is 36 characters long. I expected the output to be the same length compared to the input. Why is the output double the size of the input?

    final iv = e.IV.fromBase16(hexMessage.substring(0, 24));
    final key = e.Key.fromBase16(HEX.encode(Uint8List.fromList(aesPrivateKey!)));
    final encrypter = e.Encrypter(e.AES(key,mode: e.AESMode.ctr,padding: null)); // Gebruik AES met de gegenereerde sleutel
    final encrypted = encrypter.encrypt(hexMessage.substring(28), iv: iv); // Versleutel het bericht met de IVbericht met de IV
    print(hexMessage.substring(28));
    print(encrypted.base16);