encrypt method

String encrypt(
  1. String message,
  2. String stringReceiverPubKey
)

Implementation

String encrypt(String message, String stringReceiverPubKey) {
  final List<int> hexReceiverPubKey = HEX.decode(stringReceiverPubKey);
  final Uint8List uintReceiverPubKey = Uint8List.fromList(hexReceiverPubKey);
  final receiverPk = PublicKey(uintReceiverPubKey);

  final box = Box(myPrivateKey: privateKey, theirPublicKey: receiverPk);
  final encrypted = box.encrypt(Uint8List.fromList(utf8.encode(message)));

  return base64Encode(encrypted);
}