js的3DES加密与解密
3DES的加密与解密
Base64与Hex
Base64与Hex都属于编码形式,Hex又称Base16。在3DES的加密与解密过程中,需要进行两种编码形式的转换。
3DES的加密
首先first.html代码为
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>3DES加密</title>
</head><body><div><input id="word1" /></div><div><button id="encrypt">加密</button></div><div id="result1"></div><div><button id="decrypt">解密</button></div><div id="result2"></div>
</body>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/core.js"></script>
<script src="js/cipher-core.js"></script>
<script src="js/format-hex.js"></script>
<script src="js/tripledes.js"></script>
<script src="js/ecb.js"></script>
<script src="js/md5.js"></script>
<script src="js/first.js"></script>
</html>
引用的js文件文结尾会给。
相应的first.js文件为
var key = "b2Z14a21dfPrWX12q186wsy5";
function md5Hex(data) {return CryptoJS.MD5(data).toString();
}
$(function () {$("#encrypt").click(function () {var word1 = $("#word1").val();var ciphertext = md5Hex(word1);//MD5加密密文console.log(ciphertext);var meg = encryptByDES(ciphertext);$("#result1").text(meg);});$("#decrypt").click(function () {var word1 = $("#word1").val();var ciphertext = md5Hex(word1);//MD5加密密文var text = encryptByDES(ciphertext);//console.log(text);var md=decryptByDES(text);$("#result2").text(md);});
})
function encryptByDES(message) {var keyHex = CryptoJS.enc.Utf8.parse(key);var encrypted = CryptoJS.TripleDES.encrypt(message, keyHex, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});return encrypted.toString();
}
function decryptByDES(ciphertext) {var keyHex = CryptoJS.enc.Utf8.parse(key);var decrypted = CryptoJS.TripleDES.decrypt(ciphertext, keyHex, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});return decrypted.toString(CryptoJS.enc.Utf8);
}
需要注意的是,我使用的是输出内容的编码方式为Hex,3DES-ECB的模式。
遇到的问题
我在网上找到的cipher-core.js文件都是Base64的输出格式,Hex输出格式下加密正确,解密为空,找了好久才发现是js文件的问题,将cipher-core.js文件中的Base64定义的改成了Hex定义,这样解密结果正确,结果为原文MD5加密之后的。
cipher-core.js文件
/*** Cipher core components.*/
CryptoJS.lib.Cipher || (function (undefined) {// Shortcutsvar C = CryptoJS;var C_lib = C.lib;var Base = C_lib.Base;var WordArray = C_lib.WordArray;var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;var C_enc = C.enc;var Utf8 = C_enc.Utf8;var Hex = C_enc.Hex;var C_algo = C.algo;var EvpKDF = C_algo.EvpKDF;/*** Abstract base cipher template.** @property {number} keySize This cipher's key size. Default: 4 (128 bits)* @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)* @property {number} _ENC_XFORM_MODE A constant representing encryption mode.* @property {number} _DEC_XFORM_MODE A constant representing decryption mode.*/var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({/*** Configuration options.** @property {WordArray} iv The IV to use for this operation.*/cfg: Base.extend(),/*** Creates this cipher in encryption mode.** @param {WordArray} key The key.* @param {Object} cfg (Optional) The configuration options to use for this operation.** @return {Cipher} A cipher instance.** @static** @example** var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });*/createEncryptor: function (key, cfg) {return this.create(this._ENC_XFORM_MODE, key, cfg);},/*** Creates this cipher in decryption mode.** @param {WordArray} key The key.* @param {Object} cfg (Optional) The configuration options to use for this operation.** @return {Cipher} A cipher instance.** @static** @example** var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });*/createDecryptor: function (key, cfg) {return this.create(this._DEC_XFORM_MODE, key, cfg);},/*** Initializes a newly created cipher.** @param {number} xformMode Either the encryption or decryption transormation mode constant.* @param {WordArray} key The key.* @param {Object} cfg (Optional) The configuration options to use for this operation.** @example** var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });*/init: function (xformMode, key, cfg) {// Apply config defaultsthis.cfg = this.cfg.extend(cfg);// Store transform mode and keythis._xformMode = xformMode;this._key = key;// Set initial valuesthis.reset();},/*** Resets this cipher to its initial state.** @example** cipher.reset();*/reset: function () {// Reset data bufferBufferedBlockAlgorithm.reset.call(this);// Perform concrete-cipher logicthis._doReset();},/*** Adds data to be encrypted or decrypted.** @param {WordArray|string} dataUpdate The data to encrypt or decrypt.** @return {WordArray} The data after processing.** @example** var encrypted = cipher.process('data');* var encrypted = cipher.process(wordArray);*/process: function (dataUpdate) {// Appendthis._append(dataUpdate);// Process available blocksreturn this._process();},/*** Finalizes the encryption or decryption process.* Note that the finalize operation is effectively a destructive, read-once operation.** @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.** @return {WordArray} The data after final processing.** @example** var encrypted = cipher.finalize();* var encrypted = cipher.finalize('data');* var encrypted = cipher.finalize(wordArray);*/finalize: function (dataUpdate) {// Final data updateif (dataUpdate) {this._append(dataUpdate);}// Perform concrete-cipher logicvar finalProcessedData = this._doFinalize();return finalProcessedData;},keySize: 128/32,ivSize: 128/32,_ENC_XFORM_MODE: 1,_DEC_XFORM_MODE: 2,/*** Creates shortcut functions to a cipher's object interface.** @param {Cipher} cipher The cipher to create a helper for.** @return {Object} An object with encrypt and decrypt shortcut functions.** @static** @example** var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);*/_createHelper: (function () {function selectCipherStrategy(key) {if (typeof key == 'string') {return PasswordBasedCipher;} else {return SerializableCipher;}}return function (cipher) {return {encrypt: function (message, key, cfg) {return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);},decrypt: function (ciphertext, key, cfg) {return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);}};};}())});/*** Abstract base stream cipher template.** @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)*/var StreamCipher = C_lib.StreamCipher = Cipher.extend({_doFinalize: function () {// Process partial blocksvar finalProcessedBlocks = this._process(!!'flush');return finalProcessedBlocks;},blockSize: 1});/*** Mode namespace.*/var C_mode = C.mode = {};/*** Abstract base block cipher mode template.*/var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({/*** Creates this mode for encryption.** @param {Cipher} cipher A block cipher instance.* @param {Array} iv The IV words.** @static** @example** var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);*/createEncryptor: function (cipher, iv) {return this.Encryptor.create(cipher, iv);},/*** Creates this mode for decryption.** @param {Cipher} cipher A block cipher instance.* @param {Array} iv The IV words.** @static** @example** var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);*/createDecryptor: function (cipher, iv) {return this.Decryptor.create(cipher, iv);},/*** Initializes a newly created mode.** @param {Cipher} cipher A block cipher instance.* @param {Array} iv The IV words.** @example** var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);*/init: function (cipher, iv) {this._cipher = cipher;this._iv = iv;}});/*** Cipher Block Chaining mode.*/var CBC = C_mode.CBC = (function () {/*** Abstract base CBC mode.*/var CBC = BlockCipherMode.extend();/*** CBC encryptor.*/CBC.Encryptor = CBC.extend({/*** Processes the data block at offset.** @param {Array} words The data words to operate on.* @param {number} offset The offset where the block starts.** @example** mode.processBlock(data.words, offset);*/processBlock: function (words, offset) {// Shortcutsvar cipher = this._cipher;var blockSize = cipher.blockSize;// XOR and encryptxorBlock.call(this, words, offset, blockSize);cipher.encryptBlock(words, offset);// Remember this block to use with next blockthis._prevBlock = words.slice(offset, offset + blockSize);}});/*** CBC decryptor.*/CBC.Decryptor = CBC.extend({/*** Processes the data block at offset.** @param {Array} words The data words to operate on.* @param {number} offset The offset where the block starts.** @example** mode.processBlock(data.words, offset);*/processBlock: function (words, offset) {// Shortcutsvar cipher = this._cipher;var blockSize = cipher.blockSize;// Remember this block to use with next blockvar thisBlock = words.slice(offset, offset + blockSize);// Decrypt and XORcipher.decryptBlock(words, offset);xorBlock.call(this, words, offset, blockSize);// This block becomes the previous blockthis._prevBlock = thisBlock;}});function xorBlock(words, offset, blockSize) {var block;// Shortcutvar iv = this._iv;// Choose mixing blockif (iv) {block = iv;// Remove IV for subsequent blocksthis._iv = undefined;} else {block = this._prevBlock;}// XOR blocksfor (var i = 0; i < blockSize; i++) {words[offset + i] ^= block[i];}}return CBC;}());/*** Padding namespace.*/var C_pad = C.pad = {};/*** PKCS #5/7 padding strategy.*/var Pkcs7 = C_pad.Pkcs7 = {/*** Pads data using the algorithm defined in PKCS #5/7.** @param {WordArray} data The data to pad.* @param {number} blockSize The multiple that the data should be padded to.** @static** @example** CryptoJS.pad.Pkcs7.pad(wordArray, 4);*/pad: function (data, blockSize) {// Shortcutvar blockSizeBytes = blockSize * 4;// Count padding bytesvar nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;// Create padding wordvar paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;// Create paddingvar paddingWords = [];for (var i = 0; i < nPaddingBytes; i += 4) {paddingWords.push(paddingWord);}var padding = WordArray.create(paddingWords, nPaddingBytes);// Add paddingdata.concat(padding);},/*** Unpads data that had been padded using the algorithm defined in PKCS #5/7.** @param {WordArray} data The data to unpad.** @static** @example** CryptoJS.pad.Pkcs7.unpad(wordArray);*/unpad: function (data) {// Get number of padding bytes from last bytevar nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;// Remove paddingdata.sigBytes -= nPaddingBytes;}};/*** Abstract base block cipher template.** @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)*/var BlockCipher = C_lib.BlockCipher = Cipher.extend({/*** Configuration options.** @property {Mode} mode The block mode to use. Default: CBC* @property {Padding} padding The padding strategy to use. Default: Pkcs7*/cfg: Cipher.cfg.extend({mode: CBC,padding: Pkcs7}),reset: function () {var modeCreator;// Reset cipherCipher.reset.call(this);// Shortcutsvar cfg = this.cfg;var iv = cfg.iv;var mode = cfg.mode;// Reset block modeif (this._xformMode == this._ENC_XFORM_MODE) {modeCreator = mode.createEncryptor;} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {modeCreator = mode.createDecryptor;// Keep at least one block in the buffer for unpaddingthis._minBufferSize = 1;}if (this._mode && this._mode.__creator == modeCreator) {this._mode.init(this, iv && iv.words);} else {this._mode = modeCreator.call(mode, this, iv && iv.words);this._mode.__creator = modeCreator;}},_doProcessBlock: function (words, offset) {this._mode.processBlock(words, offset);},_doFinalize: function () {var finalProcessedBlocks;// Shortcutvar padding = this.cfg.padding;// Finalizeif (this._xformMode == this._ENC_XFORM_MODE) {// Pad datapadding.pad(this._data, this.blockSize);// Process final blocksfinalProcessedBlocks = this._process(!!'flush');} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {// Process final blocksfinalProcessedBlocks = this._process(!!'flush');// Unpad datapadding.unpad(finalProcessedBlocks);}return finalProcessedBlocks;},blockSize: 128/32});/*** A collection of cipher parameters.** @property {WordArray} ciphertext The raw ciphertext.* @property {WordArray} key The key to this ciphertext.* @property {WordArray} iv The IV used in the ciphering operation.* @property {WordArray} salt The salt used with a key derivation function.* @property {Cipher} algorithm The cipher algorithm.* @property {Mode} mode The block mode used in the ciphering operation.* @property {Padding} padding The padding scheme used in the ciphering operation.* @property {number} blockSize The block size of the cipher.* @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.*/var CipherParams = C_lib.CipherParams = Base.extend({/*** Initializes a newly created cipher params object.** @param {Object} cipherParams An object with any of the possible cipher parameters.** @example** var cipherParams = CryptoJS.lib.CipherParams.create({* ciphertext: ciphertextWordArray,* key: keyWordArray,* iv: ivWordArray,* salt: saltWordArray,* algorithm: CryptoJS.algo.AES,* mode: CryptoJS.mode.CBC,* padding: CryptoJS.pad.PKCS7,* blockSize: 4,* formatter: CryptoJS.format.OpenSSL* });*/init: function (cipherParams) {this.mixIn(cipherParams);},/*** Converts this cipher params object to a string.** @param {Format} formatter (Optional) The formatting strategy to use.** @return {string} The stringified cipher params.** @throws Error If neither the formatter nor the default formatter is set.** @example** var string = cipherParams + '';* var string = cipherParams.toString();* var string = cipherParams.toString(CryptoJS.format.OpenSSL);*/toString: function (formatter) {return (formatter || this.formatter).stringify(this);}});/*** Format namespace.*/var C_format = C.format = {};/*** OpenSSL formatting strategy.*/var OpenSSLFormatter = C_format.OpenSSL = {/*** Converts a cipher params object to an OpenSSL-compatible string.** @param {CipherParams} cipherParams The cipher params object.** @return {string} The OpenSSL-compatible string.** @static** @example** var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);*/stringify: function (cipherParams) {var wordArray;// Shortcutsvar ciphertext = cipherParams.ciphertext;var salt = cipherParams.salt;// Formatif (salt) {wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);} else {wordArray = ciphertext;}return wordArray.toString(Hex);},/*** Converts an OpenSSL-compatible string to a cipher params object.** @param {string} openSSLStr The OpenSSL-compatible string.** @return {CipherParams} The cipher params object.** @static** @example** var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);*/parse: function (openSSLStr) {var salt;// Parse Hexvar ciphertext = Hex.parse(openSSLStr);// Shortcutvar ciphertextWords = ciphertext.words;// Test for saltif (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {// Extract saltsalt = WordArray.create(ciphertextWords.slice(2, 4));// Remove salt from ciphertextciphertextWords.splice(0, 4);ciphertext.sigBytes -= 16;}return CipherParams.create({ ciphertext: ciphertext, salt: salt });}};/*** A cipher wrapper that returns ciphertext as a serializable cipher params object.*/var SerializableCipher = C_lib.SerializableCipher = Base.extend({/*** Configuration options.** @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL*/cfg: Base.extend({format: OpenSSLFormatter}),/*** Encrypts a message.** @param {Cipher} cipher The cipher algorithm to use.* @param {WordArray|string} message The message to encrypt.* @param {WordArray} key The key.* @param {Object} cfg (Optional) The configuration options to use for this operation.** @return {CipherParams} A cipher params object.** @static** @example** var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });*/encrypt: function (cipher, message, key, cfg) {// Apply config defaultscfg = this.cfg.extend(cfg);// Encryptvar encryptor = cipher.createEncryptor(key, cfg);var ciphertext = encryptor.finalize(message);// Shortcutvar cipherCfg = encryptor.cfg;// Create and return serializable cipher paramsreturn CipherParams.create({ciphertext: ciphertext,key: key,iv: cipherCfg.iv,algorithm: cipher,mode: cipherCfg.mode,padding: cipherCfg.padding,blockSize: cipher.blockSize,formatter: cfg.format});},/*** Decrypts serialized ciphertext.** @param {Cipher} cipher The cipher algorithm to use.* @param {CipherParams|string} ciphertext The ciphertext to decrypt.* @param {WordArray} key The key.* @param {Object} cfg (Optional) The configuration options to use for this operation.** @return {WordArray} The plaintext.** @static** @example** var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });* var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });*/decrypt: function (cipher, ciphertext, key, cfg) {// Apply config defaultscfg = this.cfg.extend(cfg);// Convert string to CipherParamsciphertext = this._parse(ciphertext, cfg.format);// Decryptvar plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);return plaintext;},/*** Converts serialized ciphertext to CipherParams,* else assumed CipherParams already and returns ciphertext unchanged.** @param {CipherParams|string} ciphertext The ciphertext.* @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.** @return {CipherParams} The unserialized ciphertext.** @static** @example** var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);*/_parse: function (ciphertext, format) {if (typeof ciphertext == 'string') {return format.parse(ciphertext, this);} else {return ciphertext;}}});/*** Key derivation function namespace.*/var C_kdf = C.kdf = {};/*** OpenSSL key derivation function.*/var OpenSSLKdf = C_kdf.OpenSSL = {/*** Derives a key and IV from a password.** @param {string} password The password to derive from.* @param {number} keySize The size in words of the key to generate.* @param {number} ivSize The size in words of the IV to generate.* @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.** @return {CipherParams} A cipher params object with the key, IV, and salt.** @static** @example** var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');*/execute: function (password, keySize, ivSize, salt) {// Generate random saltif (!salt) {salt = WordArray.random(64/8);}// Derive key and IVvar key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);// Separate key and IVvar iv = WordArray.create(key.words.slice(keySize), ivSize * 4);key.sigBytes = keySize * 4;// Return paramsreturn CipherParams.create({ key: key, iv: iv, salt: salt });}};/*** A serializable cipher wrapper that derives the key from a password,* and returns ciphertext as a serializable cipher params object.*/var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({/*** Configuration options.** @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL*/cfg: SerializableCipher.cfg.extend({kdf: OpenSSLKdf}),/*** Encrypts a message using a password.** @param {Cipher} cipher The cipher algorithm to use.* @param {WordArray|string} message The message to encrypt.* @param {string} password The password.* @param {Object} cfg (Optional) The configuration options to use for this operation.** @return {CipherParams} A cipher params object.** @static** @example** var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });*/encrypt: function (cipher, message, password, cfg) {// Apply config defaultscfg = this.cfg.extend(cfg);// Derive key and other paramsvar derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);// Add IV to configcfg.iv = derivedParams.iv;// Encryptvar ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);// Mix in derived paramsciphertext.mixIn(derivedParams);return ciphertext;},/*** Decrypts serialized ciphertext using a password.** @param {Cipher} cipher The cipher algorithm to use.* @param {CipherParams|string} ciphertext The ciphertext to decrypt.* @param {string} password The password.* @param {Object} cfg (Optional) The configuration options to use for this operation.** @return {WordArray} The plaintext.** @static** @example** var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });* var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });*/decrypt: function (cipher, ciphertext, password, cfg) {// Apply config defaultscfg = this.cfg.extend(cfg);// Convert string to CipherParamsciphertext = this._parse(ciphertext, cfg.format);// Derive key and other paramsvar derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);// Add IV to configcfg.iv = derivedParams.iv;// Decryptvar plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);return plaintext;}});
}());
不对的地方希望给我指正。
参考链接
https://github.com/brix/crypto-js/tree/develop/src
https://blog.csdn.net/u010081710/article/details/47398315
js的3DES加密与解密相关推荐
- 7.node.js的3DES 加密和解密的方法封装
原文:http://blog.csdn.net/ererfei/article/details/73558226 1 var assert = require('assert'); 2 var cry ...
- 探讨NET Core数据进行3DES加密或解密弱密钥问题
[导读]之前写过一篇<探讨.NET Core数据进行3DES加密和解密问题>,最近看到有人提出弱密钥问题,换个强密钥不就完了吗,猜测可能是与第三方对接导致很无奈不能更换密钥,所以产生本文解 ...
- 3DES加密、解密工具类
一个简单的3DES加密.解密工具类,Base64在 sun.misc.BASE64Decoder替代类有介绍 package com.w; import java.security.Key; impo ...
- 怎样操作vue.js使用3DES加密
如何在VUE-CLI手脚架建立的工程中使用3des加密: 1 npm install crypto-js --save-dev 1 import CryptoJS from 'crypto-js' 1 ...
- 探讨.NET Core数据进行3DES加密和解密问题
前言 一直困扰着我关于数据加密这一块,24号晚上用了接近3个小时去完成一项任务,本以为立马能解决,但是为了保证数据的安全性,我们开始去对数据进行加密,然后接下来3个小时专门去研究加密这一块,然而用着用 ...
- 3des加密 java php_java的3DES加密PHP7解密备忘录
前言: 有一个项目需要跟甲方做接口,甲方使用的是java的3DES加密解密方式. 甲方加密解密部分截图代码: 填写图片摘要(选填) 第一步: 将甲方的iv转成PHP可以使用的偏移量 填写图片摘要(选填 ...
- DES/3DES加密,解密
〇.前言 最近在项目中,涉及到与第三方厂家系统进行对接时,在参数传递过程中考虑到了数据的安全性,故双方采用3DES进行对传递参数的加解密,因此,进一步了解了下3DES的加解密算法,再次进行梳理. 一. ...
- java和js实现前端加密后端解密,后端加密前端解密(Base64)
目录 1.前端加密后端解密 2.后端加密前端解密 在前端和后端数据传输时,常常涉及到隐私数据的传输(例如用户名和密码),这时,我们就需要对隐私数据进行加密解密 1.前端加密后端解密 1.1 前端jqu ...
- js前端3des加密 后台java解密
import java.security.Key; import java.security.SecureRandom; import javax.crypto.Cipher; import java ...
最新文章
- java udp tcp协议_【java】TCP和UDP传输协议
- 使用 Azure CLI 管理 Azure 虚拟网络和 Linux 虚拟机
- 清华孵化、张钹加盟的这家公司,现在把“第三代人工智能”落地了
- 云原生落地难的五个痛点与解决方法
- 广播与P2P通道(下) -- 方案实现
- java 依赖算法_java – Maven 2 – 从传递依赖版本定义依赖版本
- 《Linux4.0设备驱动开发详解》笔记--第三章:Linux下的C编程特点
- 删文97篇!前UCLA教授竟是民科?不看好量子通信被禁言
- ant vue 离线文档_超全离线开发手册
- (编程解决)List和Hashtable都是可以存储数据的,可为什么有时选择List,有时需要Hashtable,这两个
- 操作系统思考 第一章 编译
- mysql字段有中文、英文、数字的混合排序
- JSON与XML的区别比较
- 4. 多元函数微分学
- pycharm调试bug Process finished with exit code -1073740791 (0xC0000409)
- delphi 报错AV调试方法
- node打包时遇到的问题
- maven 打包打出带依赖的和不带依赖的jiar包
- Android设备用指令查看设备mac地址的两种方法
- 卖了43.2万美元的AI画作,其实是借鉴程序员代码的“山寨货”?