How to use the js-sha256.sha256.update function in js-sha256

To help you get started, we’ve selected a few js-sha256 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FourDizzle / js-gpu-bitcoin-miner / client / src / cpu-miner.worker.js View on Github external
function mine() {
  let duration = 0
  let startTime = (new Date()).getTime()
  let batchDiff = 0
  let finished = false
  let hash
  for (let i = 0; i < batchSize; i++) {
    let block = headerIntArr.concat(nonceToByteArray(nonce))
    hash = sha256.update(block)
    hash = sha256.update(hash.digest())

    if (isHashLessThanTarget(hash.hex())) {
      console.log('submit hash:', hash.hex())
      console.log('target:', target.toString(16))
      submitWork(work, nonce)
    }

    if (nonce >= 0xFFFFFFFF) {
      batchDiff = batchSize - i + 1
      finished = true
      break;
    } else {
      nonce++
    }
  }
  duration = (new Date()).getTime() - startTime
github FourDizzle / js-gpu-bitcoin-miner / client / src / cpu-miner.worker.js View on Github external
function mine() {
  let duration = 0
  let startTime = (new Date()).getTime()
  let batchDiff = 0
  let finished = false
  let hash
  for (let i = 0; i < batchSize; i++) {
    let block = headerIntArr.concat(nonceToByteArray(nonce))
    hash = sha256.update(block)
    hash = sha256.update(hash.digest())

    if (isHashLessThanTarget(hash.hex())) {
      console.log('submit hash:', hash.hex())
      console.log('target:', target.toString(16))
      submitWork(work, nonce)
    }

    if (nonce >= 0xFFFFFFFF) {
      batchDiff = batchSize - i + 1
      finished = true
      break;
    } else {
      nonce++
    }
  }