SoFunction
Updated on 2025-03-10

Example of DES encryption implemented by JS encryption plugin CryptoJS

This article describes the DES encryption implemented by the JS encryption plugin CryptoJS. Share it for your reference, as follows:

The previous article "JS encryption plugin CryptoJS implements AES encryption operation》 introduces the simple configuration and use of the CryptoJS plug-in. Here we take a look at the method of CryptoJS implementing DES encryption:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Testing websockets</title>
<script type="text/javascript" src="jquery-1.10."></script>
<script src=""></script>
<script src=""></script>
<script type="text/javascript">
var key = 'BOTWAVEE';
//CBC mode encryptionfunction encryptByDESModeCBC(message) {
var keyHex = .(key);
    var ivHex = .(key);
    encrypted = (message, keyHex, {
iv:ivHex,
mode: ,
padding:.Pkcs7
}
    );
return ();
}
//CBC mode decryptionfunction decryptByDESModeCBC(ciphertext2) {
var keyHex = .(key);
    var ivHex = .(key);
// direct decrypt ciphertext
var decrypted = ({
ciphertext: (ciphertext2)
}, keyHex, {
iv:ivHex,
mode: ,
padding: .Pkcs7
});
return (.Utf8);
}
//DES ECB mode encryptionfunction encryptByDESModeEBC(message){
var keyHex = .(key);
var encrypted = (message, keyHex, {
mode: ,
padding: .Pkcs7
});
return ();
}
//DES ECB mode decryptionfunction decryptByDESModeEBC(ciphertext){
var keyHex = .(key);
var decrypted = ({
ciphertext: (ciphertext)
}, keyHex, {
mode: ,
padding: .Pkcs7
});
var result_value = (.Utf8);
return result_value;
}
function test(){
var source = $("#source").val();
var cc = encryptByDESModeEBC(.(source));
$("#target").val(cc);
}
function test1(){
var source = $("#sourceS").val();
var dd = decryptByDESModeEBC(source);
$("#jiemi").val(dd);
}
</script>
</head>
<body>
 <div>
Before encryption:<textarea  value="" style="width:500px;height:90px;" /></textarea>
<hr>
After encryption:<textarea  value="" style="width:500px;height:90px;" ></textarea>
<hr>
<input type="button" onclick="test();" name="" value="encryption" />
<hr>
Secret text:<textarea  value="" width="400px" style="width:500px;height:90px;" ></textarea>
<hr>
After decryption:<textarea  value="" style="width:500px;height:90px;" ></textarea>
<hr>
<input type="button" onclick="test1();" name="" value="Decryption"/>
 </div>
</body>
</html>

For DES main file, comes with CBC module

For DES ECB module

Introduced using CBC mode

Introduce + using ECB mode

PS: Friends who are interested in encryption and decryption can also refer to the online tools of this site:

OnlineDESEncryption/decryption tools:
http://tools./password/des_encode

Text online encryption and decryption tools (including AES,DES, RC4, etc.):
http://tools./password/txt_encode

Online encoding conversion tool (utf-8/utf-32/Punycode/Base64):
http://tools./transcoding/decode_encode_tool

BASE64Encoding and decoding tools:
http://tools./transcoding/base64

Online MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160 encryption tool:
http://tools./password/hash_md5_sha

Online sha1/sha224/sha256/sha384/sha512 encryption tool:
http://tools./password/sha_encode

For more information about JavaScript, please view the special topic of this site: "Summary of JavaScript encryption and decryption skills》、《Summary of JavaScript switching effects and techniques》、《Summary of JavaScript search algorithm skills》、《Summary of JavaScript animation special effects and techniques》、《Summary of JavaScript Errors and Debugging Skills》、《Summary of JavaScript data structure and algorithm techniques》、《JavaScript traversal algorithm and skills summary"and"Summary of JavaScript mathematical operations usage

I hope this article will be helpful to everyone's JavaScript programming.