encrypt method

  1. @override
BuBytes encrypt({
  1. required List<int> key,
  2. required int radix,
  3. required List<int> pt,
  4. List<int> tweak = const [],
})
override

Encrypts digit bytes pt (each < radix) with 16, 24 or 32-byte key, radix 2..65536 (Dart backend 2..256) and tweak. Returns same-length ciphertext. Throws on bad key/radix or empty pt.

Implementation

@override
BuBytes encrypt({
  required List<int> key,
  required int radix,
  required List<int> pt,
  List<int> tweak = const [],
}) {
  _checkRadix(radix, "FF1.encrypt");
  final ff1 = FF1Flexible(aes: blockCipherApi.aes(key), radix: radix);
  final enc = ff1.encrypt(FlexibleNumeralString(pt), tweak: tweak);
  return enc.digits.asBytes;
}