taggedHash function

List<int> taggedHash(
  1. List<int> data,
  2. String tag
)

Function: taggedHash Description: Computes a tagged hash of the input data with a provided tag. Input:

  • List
  • String tag - A unique tag to differentiate the hash. Output: List

Implementation

List<int> taggedHash(List<int> data, String tag) {
  /// Calculate the hash of the tag as List<int>.
  final tagDigest = QuickCrypto.sha256Hash(List<int>.from(tag.codeUnits));

  /// Concatenate the tag hash with itself and the input data.
  final concat = List<int>.from([...tagDigest, ...tagDigest, ...data]);

  /// Compute a double SHA-256 hash of the concatenated data.
  return QuickCrypto.sha256Hash(concat);
}