How to use the crypto-js/enc-hex.stringify function in crypto-js

To help you get started, we’ve selected a few crypto-js 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 peerplays-network / peerplays-core-gui / lib / ecc / src / aes.js View on Github external
decryptHexToBuffer(cipher) {
        assert(cipher, "Missing cipher text");
        // Convert data into word arrays (used by Crypto)
        var cipher_array = encHex.parse(cipher);
        var plainwords = this._decrypt_word_array(cipher_array);
        var plainhex = encHex.stringify(plainwords);
        return new Buffer(plainhex, 'hex');
    }
github bitshares / bitsharesjs / lib / ecc / src / aes.js View on Github external
decryptHexToBuffer(cipher) {
        assert(cipher, "Missing cipher text");
        // Convert data into word arrays (used by Crypto)
        var cipher_array = encHex.parse(cipher);
        var plainwords = this._decrypt_word_array(cipher_array);
        var plainhex = encHex.stringify(plainwords);
        return new Buffer(plainhex, "hex");
    }
github bitshares / bitsharesjs / lib / ecc / src / aes.js View on Github external
decryptHex(cipher) {
        assert(cipher, "Missing cipher text");
        // Convert data into word arrays (used by Crypto)
        var cipher_array = encHex.parse(cipher);
        var plainwords = this._decrypt_word_array(cipher_array);
        return encHex.stringify(plainwords);
    }
github peerplays-network / peerplays-core-gui / lib / ecc / src / aes.js View on Github external
decryptHex(cipher) {
        assert(cipher, "Missing cipher text");
        // Convert data into word arrays (used by Crypto)
        var cipher_array = encHex.parse(cipher);
        var plainwords = this._decrypt_word_array(cipher_array);
        return encHex.stringify(plainwords);
    }
github TencentCloud / tencentcloud-monitor-grafana-app / src / datasource / common / sign.ts View on Github external
getHeader() {
    // Generate the request string
    const canonicalHeaders = `content-type:${ContentType}\nhost:${this.host}\n`;
    const signedHeaders = 'content-type;host';
    const hashedRequestPayload = Hex.stringify(SHA256(this.payload)).toLowerCase();
    const canonicalRequest = `${HttpRequestMethod}\n${CanonicalUri}\n${CanonicalQueryString}\n${canonicalHeaders}\n${signedHeaders}\n${hashedRequestPayload}`;

    // Generate the original signature string
    const credentialScope = `${this.date}/${this.service}/tc3_request`;
    const hashedCanonicalRequest = Hex.stringify(SHA256(canonicalRequest)).toLowerCase();
    const stringToSign = `${Algorithm}\n${this.timestamp}\n${credentialScope}\n${hashedCanonicalRequest}`;

    // Generate the signature string
    const secretDate = HmacSHA256(this.date,`TC3${this.secretKey}`);
    const secretService = HmacSHA256(this.service, secretDate);
    const secretSigning = HmacSHA256('tc3_request', secretService);
    const signature = Hex.stringify(HmacSHA256(stringToSign,secretSigning));

    // Generate the authorization string
    const authorization = `${Algorithm} Credential=${this.secretId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;

    // Common Request Parameters of the header information
    const headers = {
      "Authorization": authorization,
      "Content-Type": ContentType,
      "X-TC-Action": this.action,
github bitshares / bitsharesjs / lib / ecc / src / aes.js View on Github external
encryptHex(plainhex) {
        var plain_array = encHex.parse(plainhex);
        var cipher_array = this._encrypt_word_array(plain_array);
        return encHex.stringify(cipher_array);
    }
}
github auth0 / idtoken-verifier / src / index.js View on Github external
atHash,
  cb
) {
  if (this.expectedAlg !== alg) {
    return cb(
      new error.TokenValidationError(
        'Signature algorithm of "' +
          alg +
          '" is not supported. Expected "' +
          this.expectedAlg +
          '"'
      )
    );
  }
  var sha256AccessToken = sha256(accessToken);
  var hashToHex = cryptoHex.stringify(sha256AccessToken);
  var hashToHexFirstHalf = hashToHex.substring(0, hashToHex.length / 2);
  var hashFirstHalfWordArray = cryptoHex.parse(hashToHexFirstHalf);
  var hashFirstHalfBase64 = cryptoBase64.stringify(hashFirstHalfWordArray);
  var hashFirstHalfBase64SafeUrl = base64.base64ToBase64Url(
    hashFirstHalfBase64
  );
  if (hashFirstHalfBase64SafeUrl !== atHash) {
    return cb(new error.TokenValidationError('Invalid access_token'));
  }
  return cb(null);
};
github NightlyCommit / twing / src / lib / profiler / node-visitor / profiler.ts View on Github external
private getVarName(): string {
        return `__internal_${hex.stringify(sha256(this.extensionName))}`;
    }
github NightlyCommit / twing / src / lib / parser.ts View on Github external
getVarName(prefix: string = '__internal_'): string {
        return `${prefix}${hex.stringify(sha256('TwingParser::getVarName' + this.stream.getSourceContext().getCode() + this.varNameSalt++))}`;
    }