encrypt method
Implementation
Uint8List encrypt(BlockCipher cipher, /* String | Iterable<int> */ input,
{required Uint8List iv, Padder? padder}) {
if (input is String) {
input = utf8.encode(input);
}
Uint8List padded;
if (padder != null) {
padded = padder.pad(cipher.blockSize, input);
} else {
padded = Uint8List.fromList(input);
}
final state = CTRState(cipher, iv);
final out = Uint8List(padded.length);
for (int i = 0; i < padded.length; i++) {
final ebyte = state.nextByte;
out[i] = padded[i] ^ ebyte;
// Debug print('Encrypt: inp: ${padded[i]}, ebyte: ${ebyte}, out: ${out[i]}');
}
return out;
}