encryptString method

Future<String> encryptString(
  1. String text
)

Encrypts a string.

Convenience method for string encryption. Uses UTF-8 encoding for the input text and Base64 for the output.

Implementation

Future<String> encryptString(String text) async {
  // Use UTF-8 encoding (not codeUnits which uses UTF-16)
  final bytes = utf8.encode(text);
  final encrypted = await encrypt(bytes);
  // Return as Base64 for safe storage/transmission of binary data
  return base64Encode(encrypted);
}