@gleif-it/vlei-verifier-workflows
Version:
Workflows for vLEI users and vLEI credentials for the vLEI-verifier service
12 lines (11 loc) • 474 B
JavaScript
import { Buffer } from 'buffer/index.js'; // this is the proper way to import the Buffer class from 'buffer'. It's needed to run Buffer in the browser.
import { createHash } from 'crypto';
export function generateFileDigest(buffer) {
const algo = 'sha256';
const digest = Buffer.from(hash(buffer, algo));
const prefixeDigest = `${algo}-${digest}`;
return prefixeDigest;
}
function hash(data, algo) {
return createHash(algo).update(data).digest('hex');
}