UNPKG

@digitalcredentials/minimal-cipher

Version:
11 lines (10 loc) 278 B
export function stringToUint8Array(data) { if(typeof data === 'string') { // convert data to Uint8Array return new TextEncoder().encode(data); } if(!(data instanceof Uint8Array)) { throw new TypeError('"data" be a string or Uint8Array.'); } return data; }