UNPKG

blocktrail-sdk

Version:

BlockTrail's Developer Friendly API binding for NodeJS

29 lines (21 loc) 835 B
var _sha256_block_size = 64, _sha256_hash_size = 32; function sha256_constructor ( options ) { options = options || {}; this.heap = _heap_init( Uint8Array, options ); this.asm = options.asm || sha256_asm( global, null, this.heap.buffer ); this.BLOCK_SIZE = _sha256_block_size; this.HASH_SIZE = _sha256_hash_size; this.reset(); } sha256_constructor.BLOCK_SIZE = _sha256_block_size; sha256_constructor.HASH_SIZE = _sha256_hash_size; var sha256_prototype = sha256_constructor.prototype; sha256_prototype.reset = hash_reset; sha256_prototype.process = hash_process; sha256_prototype.finish = hash_finish; var sha256_instance = null; function get_sha256_instance () { if ( sha256_instance === null ) sha256_instance = new sha256_constructor( { heapSize: 0x100000 } ); return sha256_instance; }