encryptPayload method

Uint8List? encryptPayload(
  1. Map<String, dynamic> data,
  2. Uint8List? nonce
)

Encrypts the data payload to be sent to Solflare Wallet.

Implementation

Uint8List? encryptPayload(Map<String, dynamic> data, Uint8List? nonce) {
  if (_sharedSecretBox == null) {
    return null;
  }

  final n = nonce ?? _core.crypto.getUtils().randomBytes(24);
  final payload = jsonEncode(data).codeUnits;
  final encryptedPayload = _sharedSecretBox?.encrypt(
    Uint8List.fromList(payload),
    nonce: n,
  );
  return encryptedPayload?.cipherText.asTypedList;
}