createSignature static method

String? createSignature(
  1. String payload,
  2. String secretKey
)

Implementation

static String? createSignature(String payload, String secretKey) {
  try {
    // Concatenate secretKey and payload
    final data = secretKey + payload;

    // Compute the SHA-256 hash
    final bytes = utf8.encode(data);
    final digest = sha256.convert(bytes);

    // Convert to Base64
    final hmacBase64 = base64Encode(digest.bytes);
    return hmacBase64;
  } catch (e) {
    print(e);
    return null;
  }
}