Closed aytunch closed 4 years ago
Ok, so you are probably going to have to go a bit more in-depth here.
The AES cipher is a block cipher, meaning that it can only encrypt strings that have lengths which are multiples of 16. The purpose of padding is to ensure that any irregular length string fills up to a length % 16 == 0; to do this, it attaches random characters to the end of the string.
Therefore, if your key/string you want to encrypt is a set length which is a multiple of 16, you actually don't use padding.:
var aesKey = CryptKey().genFortuna(32);
// This is an AES/ECB/noPadding
var crypt = AesCrypt(aesKey, 'ECB', 'pkcs7'); // Padding doesn't mean anything since length % 16 == 0
var keyToEncrypt = "XXXXXXXXXXXXXXXX"; // Length == multiple of 16
return crypt.encrypt(keyToEncrypt); // This actually has no padding
Hi @AKushWarrior , Thanks for this great package. I am trying to communicate with my MiBand using Bluetooth and the authorization requires to encrpyt a key with "AES/ECB/NoPadding". However in your wiki, it says:
Does any of those 5 padding options correspond to "No Padding"? If not, Are you planning on supporting that mode? Or it says paddings don't work in stream modes. I am not sure what it exactly is. But if I use stream mode, does that mean it will be like no padding?