Skip to content
Permalink
9bfb9ba527
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
22 lines (22 sloc) 941 Bytes
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createHash, createHmac } from "crypto";
/**
* Generates a SHA-256 HMAC signature.
* @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.
* @param stringToSign - The data to be signed.
* @param encoding - The textual encoding to use for the returned HMAC digest.
*/
export async function computeSha256Hmac(key, stringToSign, encoding) {
const decodedKey = Buffer.from(key, "base64");
return createHmac("sha256", decodedKey).update(stringToSign).digest(encoding);
}
/**
* Generates a SHA-256 hash.
* @param content - The data to be included in the hash.
* @param encoding - The textual encoding to use for the returned hash.
*/
export async function computeSha256Hash(content, encoding) {
return createHash("sha256").update(content).digest(encoding);
}
//# sourceMappingURL=sha256.js.map