How to use the crypto-browserify.createHash function in crypto-browserify

To help you get started, we’ve selected a few crypto-browserify 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 ethfinex / community-gateway / src / services / keystoreService.js View on Github external
function iter(block) {
    let hash = createHash(opts.digest || 'md5');
    hash.update(block);
    hash.update(data);
    hash.update(salt);
    block = hash.digest();
    for (let e = 1; e < (opts.count || 1); e++) {
      hash = createHash(opts.digest || 'md5');
      hash.update(block);
      block = hash.digest();
    }
    return block;
  }
github LiskHQ / lisk-sdk / src / crypto.js View on Github external
function verify(transaction) {
	let remove = 64;

	if (transaction.signSignature) {
		remove = 128;
	}

	const bytes = getBytes(transaction);
	const data2 = Buffer.alloc(bytes.length - remove);

	for (let i = 0; i < data2.length; i++) {
		data2[i] = bytes[i];
	}

	const hash = crypto.createHash('sha256').update(data2.toString('hex'), 'hex').digest();

	const signatureBuffer = Buffer.from(transaction.signature, 'hex');
	const senderPublicKeyBuffer = Buffer.from(transaction.senderPublicKey, 'hex');
	const res = naclInstance
		.crypto_sign_verify_detached(signatureBuffer, hash, senderPublicKeyBuffer);

	return res;
}
github LiskArchive / lisk-dapps-sdk / modules / blockchain / accounts.js View on Github external
Accounts.prototype.generateAddressByPublicKey = function (publicKey) {
	var publicKeyHash = crypto.createHash("sha256").update(publicKey, "hex").digest();
	var temp = new Buffer(8);
	for (var i = 0; i < 8; i++) {
		temp[i] = publicKeyHash[7 - i];
	}

	var address = bignum.fromBuffer(temp).toString() + "L";
	return address;
}
github AltCoinExchange / altcoin-plasma-sdk / src / main / services / ulotion-helper.ts View on Github external
public static hash(obj) {
    let hash = createHash('sha256');
    let result = ulotionHelper.stringify(obj);
    return hash.update(result, 'utf8').digest().toString('hex');
  }
github AltCoinExchange / altcoin-atomic-trading-platform / wallet / src / common / hashing.ts View on Github external
public hash(value: string) {
    const hashScriptBuffer = crypto.createHash("sha256").update(value).digest();
    return new RIPEMD160().update(hashScriptBuffer).digest("hex");
  }
github LiskArchive / lisk-dapps-sdk / modules / api / crypto.js View on Github external
Crypto.prototype.keypair = function (secret) {
	var hash = crypto.createHash("sha256").update(secret, "utf8").digest();
	var kp = nacl_instance.crypto_sign_keypair_from_seed(hash);

	var keypair = {
		publicKey: new Buffer(kp.signPk).toString("hex"),
		privateKey: new Buffer(kp.signSk).toString("hex")
	}

	return keypair;
}
github wellcometrust / wellcomecollection.org / catalogue / webapp / components / Auth / Auth.js View on Github external
function createLoginUrlWithVerifier() {
  const verifier = base64url(uuidv4());
  const challenge = base64url(
    crypto
      .createHash('sha256')
      .update(verifier)
      .digest()
  );

  const loginUrl = `${authDomain}/oauth2/authorize?${new URLSearchParams({
    ...authParams,
    redirect_uri: getRedirectUrl(),
    code_challenge: challenge,
    code_challenge_method: 'S256',
  }).toString()}`;

  return { loginUrl, verifier };
}
github LiskArchive / lisk-dapps-sdk / modules / blockchain / round.js View on Github external
Round.prototype.generateDelegateList = function (height) {
	var seedSource = self.calc(height).toString();

	var delegates = private.delegates.slice(0);

	var currentSeed = crypto.createHash("sha256").update(seedSource, "utf8").digest();
	for (var i = 0, delCount = delegates.length; i < delCount; i++) {
		for (var x = 0; x < 4 && i < delCount; i++, x++) {
			var newIndex = currentSeed[x] % delCount;
			var b = delegates[newIndex];
			delegates[newIndex] = delegates[i];
			delegates[i] = b;
		}
		currentSeed = crypto.createHash("sha256").update(currentSeed).digest();
	}

	return delegates;
}
github ethfinex / community-gateway / src / services / keystoreService.js View on Github external
function iter(block) {
    let hash = createHash(opts.digest || 'md5');
    hash.update(block);
    hash.update(data);
    hash.update(salt);
    block = hash.digest();
    for (let e = 1; e < (opts.count || 1); e++) {
      hash = createHash(opts.digest || 'md5');
      hash.update(block);
      block = hash.digest();
    }
    return block;
  }