Skip to content

3axap4eHko/subtlecrypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

X-Cross

Provides the standard Web Crypto API for NodeJS and Browser since both support it natively.

NPM version Downloads

Example

import { subtle } from 'xcross';

const sha256 = async (input: string) => {
  const encoder = new TextEncoder();
  const data = encoder.encode(input);
  const hashBuffer = await subtle.digest('SHA-256', data);
  const hashArray = new Uint32Array(hashBuffer);

  return hashArray.map((b) => b.toString(16).padStart(int32.BYTES_PER_ELEMENT * 2, '0')).join('');
};

License

License Apache-2.0 Copyright (c) 2023-present Ivan Zakharchanka

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published