How to use create-hmac - 7 common examples

To help you get started, we’ve selected a few create-hmac 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 AsamK / JodelJS / src / app / api.tsx View on Github external
private computeSignature(auth: string | undefined, location: string, method: string, url: string, timestamp: string,
        query: { [key: string]: any }, data: string) {
        const u = this.parseUrl(url);
        let path = u.pathname;
        if (!path.startsWith('/')) {
            path = '/' + path;
        }
        const queryPart = Object.keys(query)
            .filter(key => query[key] !== undefined)
            .map(key => encodeURIComponent(key) + '%' + encodeURIComponent(query[key]))
            .join('%');
        const raw = `${method}%${u.hostname}%${443}%${path}%${auth || ''}%${location}%${timestamp}%${queryPart}%${data}`;

        const hmac = createHmac('sha1', Settings.KEY);
        hmac.setEncoding('hex');
        hmac.write(raw);
        hmac.end();
        return hmac.read();
    }
github aws-amplify / amplify-js / packages / amazon-cognito-identity-js / src / AuthenticationHelper.js View on Github external
computehkdf(ikm, salt) {
    const prk = createHmac('sha256', salt).update(ikm).digest();
    const infoBitsUpdate = Buffer.concat([
      this.infoBits,
      Buffer.from(String.fromCharCode(1), 'utf8'),
    ]);
    const hmac = createHmac('sha256', prk).update(infoBitsUpdate).digest();
    return hmac.slice(0, 16);
  }
github aws-amplify / amplify-js / packages / amazon-cognito-identity-js / src / AuthenticationHelper.js View on Github external
computehkdf(ikm, salt) {
    const prk = createHmac('sha256', salt).update(ikm).digest();
    const infoBitsUpdate = Buffer.concat([
      this.infoBits,
      Buffer.from(String.fromCharCode(1), 'utf8'),
    ]);
    const hmac = createHmac('sha256', prk).update(infoBitsUpdate).digest();
    return hmac.slice(0, 16);
  }
github chunkai1312 / fqb / src / graph_node.js View on Github external
addAppSecretProofModifier (appSecret) {
    const accessToken = this.getModifier(GraphNode.PARAM_ACCESS_TOKEN)
    if (!accessToken) return
    this._modifiers[GraphNode.PARAM_APP_SECRET_PROOF] = createHmac('sha256', appSecret).update(accessToken).digest('hex')
  }
}
github vitelabs / vite.js / libs / hd.js View on Github external
function CKDPriv ({ key, chainCode }, index) {
    const indexBuffer = Buffer.allocUnsafe(4);
    indexBuffer.writeUInt32BE(index, 0);

    const data = Buffer.concat([Buffer.alloc(1, 0), key, indexBuffer]);

    const I = createHmac('sha512', chainCode).update(data).digest();
    const IL = I.slice(0, 32);
    const IR = I.slice(32);
    return {
        key: IL,
        chainCode: IR,
    };
}
github blockstack-packages / blockstack-keychains-js / src / derivation.es6 View on Github external
function getChildKeyMultiplier(parentKeypair, entropyBuffer) {
  const parentPublicKeyBuffer = parentKeypair.getPublicKeyBuffer()
  const childKeyMultiplier = BigInteger.fromBuffer(
    createHmac('sha256',
      Buffer.concat([parentPublicKeyBuffer, entropyBuffer])
    ).digest()
  )

  if (childKeyMultiplier.compareTo(secp256k1.n) >= 0) {
    throw new TypeError('Entropy is resulting in an invalid child scalar')
  }

  return childKeyMultiplier
}
github vitelabs / vite.js / libs / hd.js View on Github external
function getMasterKeyFromSeed (seed) {
    const hmac = createHmac('sha512', ED25519_CURVE);
    const I = hmac.update(Buffer.from(seed, 'hex')).digest();
    const IL = I.slice(0, 32);
    const IR = I.slice(32);
    return {
        key: IL,
        chainCode: IR,
    };
}

create-hmac

node style hmacs in the browser

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis

Popular create-hmac functions