UNPKG

tweetnacl-ts

Version:

Port of TweetNaCl cryptographic library to TypeScript (and ES6)

11 lines 357 B
export function validateBase64(s) { if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)) { throw new TypeError('invalid base64 string'); } } export function validateHex(s) { if (!/^(?:[A-Fa-f0-9]{2})+$/.test(s)) { throw new TypeError('invalid hex string'); } } //# sourceMappingURL=validate.js.map