UNPKG

cic-client

Version:

Typescript libraries for building CIC client applications

28 lines (20 loc) 397 B
import * as crypto from 'crypto'; const _algs = { 'SHA-256': 'sha256', } function cryptoWrapper() { } cryptoWrapper.prototype.digest = async function(s, d) { const h = crypto.createHash(_algs[s]); h.update(d); return h.digest(); } let subtle = undefined; if (typeof window !== 'undefined') { subtle = window.crypto.subtle; } else { subtle = new cryptoWrapper(); } export { subtle, }