How to use the crypto-js/enc-base64.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 linkedin / iris-mobile / src / providers / auth_interceptor / hmac_auth.ts View on Github external
.then(([key, keyId]) => {
        // Calculate HMAC text
        let expWindow = (Date.now() / 1000) | 0,
        body = request.serializeBody() || '',
        text = `${expWindow} ${request.method} ${path} ${body}`,
        digest = Base64.stringify(hmacSHA512(text, key));

        // Do URL-safe base 64 encoding (replace + and / with - and _, respectively)
        let b64Digest = digest.replace(/\+/g, '-').replace(/\//g, '_');

        // Set headers on request
        request = request.clone({
          setHeaders: {
            Authorization: `signature=${b64Digest},keyId=${keyId},timestamp=${expWindow}`,
          }
        });
        return request;
      })
    ).flatMap(req => {
github yunify / qingstor-sdk-js / src / build.js View on Github external
// Add user-agent header
    parsedHeaders['user-agent'] = util.format(
      'qingstor-sdk-js/%s (Node.js %s; %s %s)',
      version,
      process.version,
      process.platform,
      process.arch
    );

    if (this.config.additional_user_agent) {
      parsedHeaders['user-agent'] += util.format(' %s', this.config.additional_user_agent);
    }

    // Add helper for DeleteMultipleObjects
    if (operation.api === 'DeleteMultipleObjects') {
      parsedHeaders['content-md5'] = Base64.stringify(md5(this.parseRequestBody(operation)));
    }

    return filterUnsafeHeaders(parsedHeaders);
  }
github wp-pwa / wp-pwa / core / packages / analytics / shared / helpers / index.js View on Github external
export const getHash = (site, selectedItem) => {
  const { type, id, page } = selectedItem;
  const data = JSON.stringify([site, type, id, page]);
  return base64.stringify(sha256(JSON.stringify(data))).slice(0, 19);
};
github yunify / qingstor-sdk-js / src / sign.js View on Github external
calculateSignature(stringToSign) {
    const signature = Base64.stringify(hmacSHA256(stringToSign, this.secret_access_key));

    logger.debug('QingStor query request authorization: ' + signature);
    return signature;
  }
github wp-pwa / wp-pwa / core / packages / analytics / shared / utils / index.js View on Github external
export const getHash = ({ site, type, id, page }) => {
  const data = JSON.stringify([site, type, id, page]);
  return base64.stringify(sha256(JSON.stringify(data))).slice(0, 19);
};
github MixinNetwork / multisig-bot / src / api / account.js View on Github external
base64URLEncode: function (str) {
    return Base64.stringify(str)
      .replace(/\+/g, '-')
      .replace(/\//g, '_')
      .replace(/=/g, '');
  },
github lula / ngx-soap / projects / ngx-soap / src / lib / soap / utils.ts View on Github external
export const passwordDigest = function passwordDigest(nonce, created, password) {
  const rawNonce = new Buffer(nonce || '', 'base64').toString('binary');
  return Base64.stringify(sha1(rawNonce + created + password, ''));
};
github olymp / olymp / olymp / graphql / crypt.js View on Github external
exports.encrypt = (data, key) => {
  const stringifySafe = require('json-stringify-safe');
  if (!data || Object.keys(data).length === 0) return null;
  let result = stringifySafe(data);
  if (data && key) {
    const AES = require("crypto-js/aes");
    result = result ? AES.encrypt(result, key).toString() : null;
  } else {
    const Utf8 = require("crypto-js/enc-utf8");
    const Base64 = require("crypto-js/enc-base64");
    result = Base64.stringify(Utf8.parse(result));
  }
  return result;
};
exports.decrypt = (data, key) => {
github acrcloud / webapi_example / identify protocol 1 (recommended) / reactnative_ios.js View on Github external
function signString(stringToSign, accessSecret) {
  return Base64.stringify(hmacSHA1(stringToSign, accessSecret));
}
async function identify(uri, options) {