How to use the crypto-js.mode 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 olymp / olymp / external / crypt / cryptojs-v1.es6 View on Github external
export const encrypt = (m, pass) => {
  const msg = JSON.stringify(m);
  const salt = CryptoJS.lib.WordArray.random(128 / 8);

  const key = CryptoJS.PBKDF2(pass, salt, {
    keySize: keySize / 32,
    iterations
  });

  const iv = CryptoJS.lib.WordArray.random(128 / 8);

  const encrypted = CryptoJS.AES.encrypt(msg, key, {
    iv,
    padding: CryptoJS.pad.Pkcs7,
    mode: CryptoJS.mode.CBC
  });

  // salt, iv will be hex 32 in length
  // append them to the ciphertext for use  in decryption
  const transitmessage = salt.toString() + iv.toString() + encrypted.toString();
  return transitmessage;
};
github Loxone / lxcommunicator / modules / HttpRequest.js View on Github external
_aesDecryptedUtf8: function _aesDecryptedUtf8(ciphertext_base64, key_hex, iv_hex) {
                ciphertext_base64 = ciphertext_base64.replace(/\n/, "");
                var ciphertext_hex = this._checkBlockSize(this._b64ToHex(ciphertext_base64), 16); // the blockSize is 16
                var cipherParams = CryptoJS.lib.CipherParams.create({
                    ciphertext: CryptoJS.enc.Hex.parse(ciphertext_hex)
                });
                var decrypted = CryptoJS.AES.decrypt(
                    cipherParams,
                    CryptoJS.enc.Hex.parse(key_hex),
                    {
                        iv: CryptoJS.enc.Hex.parse(iv_hex),
                        mode: CryptoJS.mode.CBC,
                        padding: CryptoJS.pad.ZeroPadding
                    }
                );
                return decrypted.toString(CryptoJS.enc.Utf8);
            },
github phodal / mopass / docs / poc / encrypt.js View on Github external
function decrypt(word) {
  let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
  let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
  let decrypt = CryptoJS.AES.decrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
  let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
  return decryptedStr.toString();
}
github chucklqsun / WxJumpHelper / wx_t1t_hack.js View on Github external
function encrypt (text, originKey) {
    originKey = originKey.slice(0, 16);
    var key = CryptoJS.enc.Utf8.parse(originKey),
        iv = CryptoJS.enc.Utf8.parse(originKey),
        msg = JSON.stringify(text);
    var ciphertext = CryptoJS.AES.encrypt(msg, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return ciphertext.toString()
}
github doramart / DoraCMS / server / lib / utils / crypto.js View on Github external
encrypt: (message) => {//加密
			return CryptoJS.AES.encrypt(message, AESkey, {
				mode: CryptoJS.mode.CBC,
				padding: CryptoJS.pad.Pkcs7
			}).toString();
		},
		decrypt: (encrypt) => {//解密
github Loxone / lxcommunicator / modules / HttpRequest.js View on Github external
_aesEncryptedBase64: function _aesEncryptedBase64(payload, key, iv) {
                var encrypted = CryptoJS.AES.encrypt(
                    payload,
                    CryptoJS.enc.Hex.parse(key),
                    {
                        iv: CryptoJS.enc.Hex.parse(iv),
                        mode: CryptoJS.mode.CBC,
                        padding: CryptoJS.pad.ZeroPadding
                    }
                );
                return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
            },
github kalakalaxyz / singleStore / frontEnd / src / mixins / index.js View on Github external
encrypt(data) {
        const CryptoJS = require('crypto-js'); //引用AES源码js 
        const key = CryptoJS.enc.Utf8.parse("1234123412ABCDEF");
        const iv = CryptoJS.enc.Utf8.parse('ABCDEF1234123412');
        let srcs = CryptoJS.enc.Utf8.parse(data); 
        let encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); 
        return encrypted.ciphertext.toString().toUpperCase();
    },
    imgUpload(e, cb) {
github foliojs / pdfkit / lib / security.js View on Github external
function getUserEncryptionKeyR5(
  processedUserPassword,
  userKeySalt,
  encryptionKey
) {
  const key = CryptoJS.SHA256(
    processedUserPassword.clone().concat(userKeySalt)
  );
  const options = {
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.NoPadding,
    iv: CryptoJS.lib.WordArray.create(null, 16)
  };
  return CryptoJS.AES.encrypt(encryptionKey, key, options).ciphertext;
}
github aoju / lancia / src / app / shared / utils / security.utils.class.js View on Github external
static decrypt(val) {
        let bytes = CryptoJS.AES.decrypt(val, CryptoJS.enc.Utf8.parse(criteria.CRYPTOJS_KEY), {iv: CryptoJS.enc.Utf8.parse(criteria.CRYPTOJS_IV),mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7});
        return bytes.toString(CryptoJS.enc.Utf8);
    }
github Loxone / lxcommunicator / vendor / CryptoAdapter.js View on Github external
CryptoAdapter.aesEncrypt = function aesEncrypt(plaintext, key_hex, iv_hex) {
        return CryptoJS.AES.encrypt(
            plaintext,
            CryptoJS.enc.Hex.parse(key_hex),
            {
                iv: CryptoJS.enc.Hex.parse(iv_hex),
                mode: CryptoJS.mode.CBC,
                padding: CryptoJS.pad.ZeroPadding
            }
        );
    };