Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
15 lines
570 B
Plaintext
15 lines
570 B
Plaintext
import { mapCoseAlgToWebCryptoAlg } from './mapCoseAlgToWebCryptoAlg.js';
|
|
import { getWebCrypto } from './getWebCrypto.js';
|
|
/**
|
|
* Generate a digest of the provided data.
|
|
*
|
|
* @param data The data to generate a digest of
|
|
* @param algorithm A COSE algorithm ID that maps to a desired SHA algorithm
|
|
*/
|
|
export async function digest(data, algorithm) {
|
|
const WebCrypto = await getWebCrypto();
|
|
const subtleAlgorithm = mapCoseAlgToWebCryptoAlg(algorithm);
|
|
const hashed = await WebCrypto.subtle.digest(subtleAlgorithm, data);
|
|
return new Uint8Array(hashed);
|
|
}
|