@provenanceio/wallet-utils
Version:
Typescript Utilities for Provenance Blockchain Wallet
13 lines (12 loc) • 450 B
JavaScript
import { createHash } from 'crypto';
import { bufferToBytes } from '@tendermint/belt';
/**
* sha256 encryption of a byte array
* @param bytes a byte array (Uint8Array)
* @returns a sha256 encryted version of the given byte array
*/
export var sha256 = function sha256(bytes) {
var buffer1 = bytes instanceof Buffer ? bytes : Buffer.from(bytes);
var buffer2 = createHash('sha256').update(buffer1).digest();
return bufferToBytes(buffer2);
};