decrypt method

String decrypt(
  1. String message,
  2. String stringSenderPubKey
)

Implementation

String decrypt(String message, String stringSenderPubKey) {
  final Uint8List msg = base64.decode(message);

  final List<int> hexSenderPubKey = HEX.decode(stringSenderPubKey);
  final Uint8List uintSenderPubKey = Uint8List.fromList(hexSenderPubKey);
  final senderPk = PublicKey(uintSenderPubKey);

  final box = Box(myPrivateKey: privateKey, theirPublicKey: senderPk);
  final decrypted = box.decrypt(EncryptedMessage.fromList(msg));

  return utf8.decode(decrypted);
}