How to use ripemd160 - 9 common examples

To help you get started, we’ve selected a few ripemd160 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 blockstack / blockstack-core / core-contracts / src / bns-client.ts View on Github external
async namePreorder(namespace: string,
                     name: string,
                     salt: string,
                     STX: number, 
                     params: { sender: string }): Promise {
    let fqn = `${name}.${namespace}`;
    let sha256 = new shajs.sha256().update(fqn).digest();
    let hash160 = new ripemd160().update(sha256).digest('hex');
    let hashedFqn = `0x${hash160}`;
    console.log(hashedFqn);
    const tx = this.createTransaction({
      method: { name: "name-preorder", args: [`${hashedFqn}`, `u${STX}`] }
    });
    await tx.sign(params.sender);
    const res = await this.submitTransaction(tx);
    return res;
  }
github blockstack / blockstack-core / core-contracts / src / bns-client.ts View on Github external
async namespacePreorder(namespace: string, 
                          salt: string,
                          STX: number, 
                          params: { sender: string }): Promise {
    if (namespace === '') {
      throw new Error("Namespace can't be empty");
    }
    if (STX <= 0) {
      throw new Error("STX should be non-zero positive");
    }

    let sha256 = new shajs.sha256().update(`${namespace}${salt}`).digest();
    let hash160 = new ripemd160().update(sha256).digest('hex');
    let hashedNamespace = `0x${hash160}`;
    const tx = this.createTransaction({
      method: { name: "namespace-preorder", args: [`${hashedNamespace}`, `u${STX}`] }
    });
    await tx.sign(params.sender);
    const res = await this.submitTransaction(tx);
    return res;
  }
github loomnetwork / loom-js / signature.js View on Github external
export function pubKeyAddress(pubKey) {
    const encKey = new Writer();
    writeObject(encKey, new Buffer(pubKey.inner));

    const hasher = new ripemd160();
    hasher.update(new Buffer([typeEd25519]));
    hasher.update(encKey.getBuffer());
    return new Uint8Array(hasher.digest())
}
github loomnetwork / loom-js / src / address.ts View on Github external
static fromPublicKey(publicKey: Uint8Array): LocalAddress {
    if (publicKey.length !== 32) {
      throw new Error(`Invalid public key, expected 32 bytes, go ${publicKey.length}`)
    }
    const hasher = new ripemd160()
    hasher.update(
      Buffer.from(publicKey.buffer as ArrayBuffer, publicKey.byteOffset, publicKey.byteLength)
    )
    return new LocalAddress(hasher.digest())
  }
}
github lino-network / lino-js / src / util / index.ts View on Github external
export function addressFromPubKey(pubKeyHex: string): string {
  var ec = new EC('secp256k1');
  var key = ByteBuffer.fromHex(decodePubKey(pubKeyHex));
  const hashResult = shajs('sha256')
    .update(key.view)
    .digest() as string;
  var addr = new RIPEMD160().update(hashResult).digest('hex');
  return addr;
}
github crm416 / script / src / crypto.js View on Github external
ripemd160(data) {
        data = data.toString(base);
        return require('ripemd160')(data).toString('hex');
    },
    sha1(data) {

ripemd160

Compute ripemd160 of bytes or strings.

MIT
Latest version published 6 years ago

Package Health Score

68 / 100
Full package analysis

Popular ripemd160 functions