UNPKG

expo-crypto-universal

Version:

Universal crypto implementation for Expo that works across all platforms including web

2 lines (1 loc) 530 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class n{getRandomBytes(e){return this.getRandomValues(new Uint8Array(e))}async sha2Async(e,s){switch(e){case 256:return this.sha256Async(s);case 384:return this.sha384Async(s);case 512:return this.sha512Async(s);default:throw new Error(`Unsupported SHA-${e} hash`)}}}const r=()=>{var t;return typeof window<"u"&&typeof((t=window==null?void 0:window.crypto)==null?void 0:t.getRandomValues)=="function"};exports.AbstractCryptoModule=n;exports.isWeb=r;