`

JAVA与.NET的同步DES加解密

    博客分类:
  • java
 
阅读更多

.NET中DES加解密

  #region DESEnCode DES加密
public static string DESEnCode(string pToEncrypt, string sKey)
{ pToEncrypt = HttpContext.Current.Server.UrlEncode(pToEncrypt);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
des.Mode = System.Security.Cryptography.CipherMode.ECB;
byte[] inputByteArray = Encoding.GetEncoding("UTF-8").GetBytes(pToEncrypt);
//建立加密对象的密钥和偏移量
//原文使用ASCIIEncoding.ASCII方法的GetBytes方法
//使得输入密码必须输入英文文本
des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret = new StringBuilder();
foreach (byte b in ms.ToArray())
{ ret.AppendFormat("{0:X2}", b);
} ret.ToString();
return ret.ToString();
} #endregion
#region DESDeCode DES解密
public static string DESDeCode(string pToDecrypt, string sKey)
{ // HttpContext.Current.Response.Write(pToDecrypt + "<br>" + sKey);
// HttpContext.Current.Response.End();
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
des.Mode = System.Security.Cryptography.CipherMode.ECB;
byte[] inputByteArray = new byte[pToDecrypt.Length / 2];
for (int x = 0; x < pToDecrypt.Length / 2; x++)
{ int i = (Convert.ToInt32(pToDecrypt.Substring(x * 2, 2), 16));
inputByteArray[x] = (byte)i;
} des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret = new StringBuilder();
return HttpContext.Current.Server.UrlDecode(System.Text.Encoding.Default.GetString(ms.ToArray()));
} #endregion

 

 java与上面.NET同步的DES加解密

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
public class Encrypt {
public static String myDecrypt(String message, String key) throws Exception {
byte[] bytesrc = convertHexString(message);
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("US-ASCII"));
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
IvParameterSpec iv = new IvParameterSpec(key.getBytes("US-ASCII"));
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
byte[] retByte = cipher.doFinal(bytesrc);
return new String(retByte);
} public static String myEncrypt(String message, String key) throws Exception {
//message = java.net.URLEncoder.encode(message, "ascii");
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("US-ASCII"));
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
IvParameterSpec iv = new IvParameterSpec(key.getBytes("US-ASCII"));
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
byte[] encryptbyte = cipher.doFinal(message.getBytes());
return toHexString(encryptbyte).toUpperCase();
} public static byte[] convertHexString(String ss) {
byte digest[] = new byte[ss.length() / 2];
for (int i = 0; i < digest.length; i++) {
String byteString = ss.substring(2 * i, 2 * i + 2);
int byteValue = Integer.parseInt(byteString, 16);
digest[i] = (byte) byteValue;
} return digest;
} public static String toHexString(byte b[]) {
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < b.length; i++) {
String plainText = Integer.toHexString(0xff & b[i]);
if (plainText.length() < 2)
plainText = "0" + plainText;
hexString.append(plainText);
} return hexString.toString();
} }

JS单独的DES加解密

<html>
<head>
<title>DES加密</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb3212">
<script type="text/javascript">
<!--//des加解密函数
//key:加密用的密钥
//message:需要加密的字符串
//encrypt:加密还是解密,1为加密,0,解密
function des(key,message,encrypt,mode,iv){
//declaring this locally speeds things up a bit
var spfunction1=new Array(0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004);
var spfunction2=new Array(-0x7fef7fe0,-0x7fff8000,0x8000,0x108020,0x100000,0x20,-0x7fefffe0,-0x7fff7fe0,-0x7fffffe0,-0x7fef7fe0,-0x7fef8000,-0x80000000,-0x7fff8000,0x100000,0x20,-0x7fefffe0,0x108000,0x100020,-0x7fff7fe0,0,-0x80000000,0x8000,0x108020,-0x7ff00000,0x100020,-0x7fffffe0,0,0x108000,0x8020,-0x7fef8000,-0x7ff00000,0x8020,0,0x108020,-0x7fefffe0,0x100000,-0x7fff7fe0,-0x7ff00000,-0x7fef8000,0x8000,-0x7ff00000,-0x7fff8000,0x20,-0x7fef7fe0,0x108020,0x20,0x8000,-0x80000000,0x8020,-0x7fef8000,0x100000,-0x7fffffe0,0x100020,-0x7fff7fe0,-0x7fffffe0,0x100020,0x108000,0,-0x7fff8000,0x8020,-0x80000000,-0x7fefffe0,-0x7fef7fe0,0x108000);
var spfunction3=new Array(0x208,0x8020200,0,0x8020008,0x8000200,0,0x20208,0x8000200,0x20008,0x8000008,0x8000008,0x20000,0x8020208,0x20008,0x8020000,0x208,0x8000000,0x8,0x8020200,0x200,0x20200,0x8020000,0x8020008,0x20208,0x8000208,0x20200,0x20000,0x8000208,0x8,0x8020208,0x200,0x8000000,0x8020200,0x8000000,0x20008,0x208,0x20000,0x8020200,0x8000200,0,0x200,0x20008,0x8020208,0x8000200,0x8000008,0x200,0,0x8020008,0x8000208,0x20000,0x8000000,0x8020208,0x8,0x20208,0x20200,0x8000008,0x8020000,0x8000208,0x208,0x8020000,0x20208,0x8,0x8020008,0x20200);
var spfunction4=new Array(0x802001,0x2081,0x2081,0x80,0x802080,0x800081,0x800001,0x2001,0,0x802000,0x802000,0x802081,0x81,0,0x800080,0x800001,0x1,0x2000,0x800000,0x802001,0x80,0x800000,0x2001,0x2080,0x800081,0x1,0x2080,0x800080,0x2000,0x802080,0x802081,0x81,0x800080,0x800001,0x802000,0x802081,0x81,0,0,0x802000,0x2080,0x800080,0x800081,0x1,0x802001,0x2081,0x2081,0x80,0x802081,0x81,0x1,0x2000,0x800001,0x2001,0x802080,0x800081,0x2001,0x2080,0x800000,0x802001,0x80,0x800000,0x2000,0x802080);
var spfunction5=new Array(0x100,0x2080100,0x2080000,0x42000100,0x80000,0x100,0x40000000,0x2080000,0x40080100,0x80000,0x2000100,0x40080100,0x42000100,0x42080000,0x80100,0x40000000,0x2000000,0x40080000,0x40080000,0,0x40000100,0x42080100,0x42080100,0x2000100,0x42080000,0x40000100,0,0x42000000,0x2080100,0x2000000,0x42000000,0x80100,0x80000,0x42000100,0x100,0x2000000,0x40000000,0x2080000,0x42000100,0x40080100,0x2000100,0x40000000,0x42080000,0x2080100,0x40080100,0x100,0x2000000,0x42080000,0x42080100,0x80100,0x42000000,0x42080100,0x2080000,0,0x40080000,0x42000000,0x80100,0x2000100,0x40000100,0x80000,0,0x40080000,0x2080100,0x40000100);
var spfunction6=new Array(0x20000010,0x20400000,0x4000,0x20404010,0x20400000,0x10,0x20404010,0x400000,0x20004000,0x404010,0x400000,0x20000010,0x400010,0x20004000,0x20000000,0x4010,0,0x400010,0x20004010,0x4000,0x404000,0x20004010,0x10,0x20400010,0x20400010,0,0x404010,0x20404000,0x4010,0x404000,0x20404000,0x20000000,0x20004000,0x10,0x20400010,0x404000,0x20404010,0x400000,0x4010,0x20000010,0x400000,0x20004000,0x20000000,0x4010,0x20000010,0x20404010,0x404000,0x20400000,0x404010,0x20404000,0,0x20400010,0x10,0x4000,0x20400000,0x404010,0x4000,0x400010,0x20004010,0,0x20404000,0x20000000,0x400010,0x20004010);
var spfunction7=new Array(0x200000,0x4200002,0x4000802,0,0x800,0x4000802,0x200802,0x4200800,0x4200802,0x200000,0,0x4000002,0x2,0x4000000,0x4200002,0x802,0x4000800,0x200802,0x200002,0x4000800,0x4000002,0x4200000,0x4200800,0x200002,0x4200000,0x800,0x802,0x4200802,0x200800,0x2,0x4000000,0x200800,0x4000000,0x200800,0x200000,0x4000802,0x4000802,0x4200002,0x4200002,0x2,0x200002,0x4000000,0x4000800,0x200000,0x4200800,0x802,0x200802,0x4200800,0x802,0x4000002,0x4200802,0x4200000,0x200800,0,0x2,0x4200802,0,0x200802,0x4200000,0x800,0x4000002,0x4000800,0x800,0x200002);
var spfunction8=new Array(0x10001040,0x1000,0x40000,0x10041040,0x10000000,0x10001040,0x40,0x10000000,0x40040,0x10040000,0x10041040,0x41000,0x10041000,0x41040,0x1000,0x40,0x10040000,0x10000040,0x10001000,0x1040,0x41000,0x40040,0x10040040,0x10041000,0x1040,0,0,0x10040040,0x10000040,0x10001000,0x41040,0x40000,0x41040,0x40000,0x10041000,0x1000,0x40,0x10040040,0x1000,0x41040,0x10001000,0x40,0x10000040,0x10040000,0x10040040,0x10000000,0x40000,0x10001040,0,0x10041040,0x40040,0x10000040,0x10040000,0x10001000,0x10001040,0,0x10041040,0x41000,0x41000,0x1040,0x1040,0x40040,0x10000000,0x10041000);
//create the 16 or 48 subkeys we will need
var keys=des_createKeys(key);
var m=0,i,j,temp,temp2,right1,right2,left,right,looping;
var cbcleft,cbcleft2,cbcright,cbcright2
var endloop,loopinc;
var len=message.length;
var chunk=0;
//set up the loops for single and triple des
var iterations=keys.length==32?3 :9;//single or triple des
if(iterations==3){looping=encrypt?new Array(0,32,2):new Array(30,-2,-2);}
else{looping=encrypt?new Array(0,32,2,62,30,-2,64,96,2):new Array(94,62,-2,32,64,2,30,-2,-2);}
message+="\0\0\0\0\0\0\0\0";//pad the message out with null bytes
//store the result here
result="";
tempresult="";
if(mode==1){//CBC mode
cbcleft=(iv.charCodeAt(m++)<<24)|(iv.charCodeAt(m++)<<16)|(iv.charCodeAt(m++)<<8)|iv.charCodeAt(m++);
cbcright=(iv.charCodeAt(m++)<<24)|(iv.charCodeAt(m++)<<16)|(iv.charCodeAt(m++)<<8)|iv.charCodeAt(m++);
m=0; } //loop through each 64 bit chunk of the message
while(m<len){
if(encrypt){/*加密时按双字节操作*/
left=(message.charCodeAt(m++)<<16)|message.charCodeAt(m++);
right=(message.charCodeAt(m++)<<16)|message.charCodeAt(m++);
}else{ left=(message.charCodeAt(m++)<<24)|(message.charCodeAt(m++)<<16)|(message.charCodeAt(m++)<<8)|message.charCodeAt(m++);
right=(message.charCodeAt(m++)<<24)|(message.charCodeAt(m++)<<16)|(message.charCodeAt(m++)<<8)|message.charCodeAt(m++);
} //for Cipher Block Chaining mode,xor the message with the previous result
if(mode==1){if(encrypt){left^=cbcleft;right^=cbcright;}else{cbcleft2=cbcleft;cbcright2=cbcright;cbcleft=left;cbcright=right;}}
//first each 64 but chunk of the message must be permuted according to IP
temp=((left>>>4)^right)&0x0f0f0f0f;right^=temp;left^=(temp<<4);
temp=((left>>>16)^right)&0x0000ffff;right^=temp;left^=(temp<<16);
temp=((right>>>2)^left)&0x33333333;left^=temp;right^=(temp<<2);
temp=((right>>>8)^left)&0x00ff00ff;left^=temp;right^=(temp<<8);
temp=((left>>>1)^right)&0x55555555;right^=temp;left^=(temp<<1);
left=((left<<1)|(left>>>31));
right=((right<<1)|(right>>>31));
//do this either 1 or 3 times for each chunk of the message
for(j=0;j<iterations;j+=3){
endloop=looping[j+1];
loopinc=looping[j+2];
//now go through and perform the encryption or decryption
for(i=looping[j];i!=endloop;i+=loopinc){//for efficiency
right1=right^keys[i];
right2=((right>>>4)|(right<<28))^keys[i+1];
//the result is attained by passing these bytes through the S selection functions
temp=left;
left=right;
right=temp^(spfunction2[(right1>>>24)&0x3f]|spfunction4[(right1>>>16)&0x3f]|spfunction6[(right1>>>8)&0x3f]|spfunction8[right1&0x3f]|spfunction1[(right2>>>24)&0x3f]|spfunction3[(right2>>>16)&0x3f]|spfunction5[(right2>>>8)&0x3f]|spfunction7[right2&0x3f]);
} temp=left;left=right;right=temp;//unreverse left and right
}//for either 1 or 3 iterations
//move then each one bit to the right
left=((left>>>1)|(left<<31));
right=((right>>>1)|(right<<31));
//now perform IP-1,which is IP in the opposite direction
temp=((left>>>1)^right)&0x55555555;right^=temp;left^=(temp<<1);
temp=((right>>>8)^left)&0x00ff00ff;left^=temp;right^=(temp<<8);
temp=((right>>>2)^left)&0x33333333;left^=temp;right^=(temp<<2);
temp=((left>>>16)^right)&0x0000ffff;right^=temp;left^=(temp<<16);
temp=((left>>>4)^right)&0x0f0f0f0f;right^=temp;left^=(temp<<4);
//for Cipher Block Chaining mode,xor the message with the previous result
if(mode==1){if(encrypt){cbcleft=left;cbcright=right;}else{left^=cbcleft2;right^=cbcright2;}}
if(encrypt){tempresult+=String.fromCharCode((left>>>24),((left>>>16)&0xff),((left>>>8)&0xff),(left&0xff),(right>>>24),((right>>>16)&0xff),((right>>>8)&0xff),(right&0xff));}
else{tempresult+=String.fromCharCode(((left>>>16)&0xffff), (left&0xffff),((right>>>16)&0xffff), (right&0xffff));}/*解密时输出双字节*/
encrypt?chunk+=16:chunk+=8;
if(chunk==512){result+=tempresult;tempresult="";chunk=0;}
}//for every 8 characters,or 64 bits in the message
//return the result as an array
return result+tempresult;
}//end of des
//des_createKeys
//this takes as input a 64 bit key(even though only 56 bits are used)
//as an array of 2 integers,and returns 16 48 bit keys
function des_createKeys(key){
//declaring this locally speeds things up a bit
pc2bytes0=new Array(0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204);
pc2bytes1=new Array(0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101);
pc2bytes2=new Array(0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808);
pc2bytes3=new Array(0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000);
pc2bytes4=new Array(0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010);
pc2bytes5=new Array(0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420);
pc2bytes6=new Array(0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002);
pc2bytes7=new Array(0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800);
pc2bytes8=new Array(0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002);
pc2bytes9=new Array(0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408);
pc2bytes10=new Array(0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020);
pc2bytes11=new Array(0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200);
pc2bytes12=new Array(0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010);
pc2bytes13=new Array(0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105);
//how many iterations(1 for des,3 for triple des)
var iterations=key.length>=24?3 :1;
//stores the return keys
var keys=new Array(32 * iterations);
//now define the left shifts which need to be done
var shifts=new Array(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0);
//other variables
var lefttemp,righttemp,m=0,n=0,temp;
for(var j=0;j<iterations;j++){//either 1 or 3 iterations
left=(key.charCodeAt(m++)<<24)|(key.charCodeAt(m++)<<16)|(key.charCodeAt(m++)<<8)|key.charCodeAt(m++);
right=(key.charCodeAt(m++)<<24)|(key.charCodeAt(m++)<<16)|(key.charCodeAt(m++)<<8)|key.charCodeAt(m++);
temp=((left>>>4)^right)&0x0f0f0f0f;right^=temp;left^=(temp<<4);
temp=((right>>>-16)^left)&0x0000ffff;left^=temp;right^=(temp<<-16);
temp=((left>>>2)^right)&0x33333333;right^=temp;left^=(temp<<2);
temp=((right>>>-16)^left)&0x0000ffff;left^=temp;right^=(temp<<-16);
temp=((left>>>1)^right)&0x55555555;right^=temp;left^=(temp<<1);
temp=((right>>>8)^left)&0x00ff00ff;left^=temp;right^=(temp<<8);
temp=((left>>>1)^right)&0x55555555;right^=temp;left^=(temp<<1);
//the right side needs to be shifted and to get the last four bits of the left side
temp=(left<<8)|((right>>>20)&0x000000f0);
//left needs to be put upside down
left=(right<<24)|((right<<8)&0xff0000)|((right>>>8)&0xff00)|((right>>>24)&0xf0);
right=temp;
//now go through and perform these shifts on the left and right keys
for(i=0;i<shifts.length;i++){
//shift the keys either one or two bits to the left
if(shifts[i]){left=(left<<2)|(left>>>26);right=(right<<2)|(right>>>26);}
else{left=(left<<1)|(left>>>27);right=(right<<1)|(right>>>27);}
left&=-0xf;right&=-0xf;
//now apply PC-2,in such a way that E is easier when encrypting or decrypting
//this conversion will look like PC-2 except only the last 6 bits of each byte are used
//rather than 48 consecutive bits and the order of lines will be according to
//how the S selection functions will be applied:S2,S4,S6,S8,S1,S3,S5,S7
lefttemp=pc2bytes0[left>>>28]|pc2bytes1[(left>>>24)&0xf]
|pc2bytes2[(left>>>20)&0xf]|pc2bytes3[(left>>>16)&0xf]
|pc2bytes4[(left>>>12)&0xf]|pc2bytes5[(left>>>8)&0xf]
|pc2bytes6[(left>>>4)&0xf];
righttemp=pc2bytes7[right>>>28]|pc2bytes8[(right>>>24)&0xf]
|pc2bytes9[(right>>>20)&0xf]|pc2bytes10[(right>>>16)&0xf]
|pc2bytes11[(right>>>12)&0xf]|pc2bytes12[(right>>>8)&0xf]
|pc2bytes13[(right>>>4)&0xf];
temp=((righttemp>>>16)^lefttemp)&0x0000ffff;
keys[n++]=lefttemp^temp;keys[n++]=righttemp^(temp<<16);
} }//for each iterations
//return the keys we"ve created
return keys;
}//end of des_createKeys
////////////////////////////// 测试 //////////////////////////////
function stringToHex(s){
var r=""; var hexes=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
for(var i=0;i<(s.length);i++){r+=hexes[s.charCodeAt(i)>>4]+hexes[s.charCodeAt(i)&0xf];}
return r; }
function HexTostring(s){
var r=""; for(var i=0;i<s.length;i+=2){
var sxx=parseInt(s.substring(i,i+2),16);
r+=String.fromCharCode(sxx);}
return r; }
function needkey(){
if(document.encme.deskey.value==""){var tk=window.prompt("请设定密码!","");if(tk){document.encme.deskey.value=tk; return true;}else return false;}
else return true;
} function encMe(){
if(!needkey())return;
var k=document.encme.deskey.value;
var s=document.encme.inps.value;
document.encme.outs.value=stringToHex(des(k,s,1,0));
} function uncMe(){
if(!needkey())return;
var s=document.encme.outs.value;
document.encme.inps.value=des(document.encme.deskey.value,HexTostring(s),0,0);
} //-->
</script>
<style type="text/css">
</style>
</head>
<body>
<table border=0>
<form name="encme">
<tr><td>原
<br />
文</td><td>
<textarea name="inps" cols="50" rows="10"></textarea>
</td></tr>
<tr><td>
密 <br />
码</td><td>
<input type="password" name="deskey" maxlength="100" size="16" value="">
<input type="button" onclick="javascript:encMe()" value="&#8595;加密&#8595;">
<input type="button" onclick="javascript:uncMe()" value="&#8593;解密&#8593;">
</td></tr>
<tr><td>
密 <br />
文</td><td>
<textarea name="outs" cols="50" rows="10"></textarea>
</td></tr>
</form>
</table>
</body>
</html>
分享到:
评论

相关推荐

    java常用工具类——个人总结

    - `javax.crypto` 包提供了加密和解密功能,如`Cipher`类可以实现AES、DES等加密算法。 2. **上传工具类**: - `java.io` 和 `java.nio` 包下的类,如`FileInputStream`、`FileOutputStream`、`...

    c# bccrypto-csharp-1.8.5源码

    8. **安全更新**:每个新版本通常会修复已知的安全漏洞,以保持与最新安全实践同步。 9. **性能优化**:1.8.5版本可能包含了一些性能提升,使得加密和解密操作更加高效。 10. **跨平台兼容性**:BouncyCastle的C#...

    sim_management

    Java提供了`java.net`和`javax.comm`包,支持TCP/IP和串行通信,可用于建立网络连接和控制SIM卡模块。 4. **加密解密**:SIM卡通常存储有加密的数据,如鉴权密钥。Java内置了强大的加密库(`java.security`),支持...

    计算机毕业设计选题参考.pdf

    1. **多线程与线程安全**:Java多线程编程是并发处理的关键,涉及到线程同步、互斥、死锁等问题。学习者需要理解synchronized关键字、wait/notify机制以及Lock接口等线程安全策略。 2. **TCP/IP协议**:在断点续传...

    55links友情链接网址跟踪器

    55links友情链接网址跟踪器,放在桌面,每次直接打开就可以访问55links友情链接交易平台,方便快捷。

    [AB PLC例程源码][MMS_046180]CompactFlash Data Storage.zip

    AB PLC例程代码项目案例 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!

    moore_01_0909.pdf

    moore_01_0909

    FIBR English learning

    FIBR English learning

    [AB PLC例程源码][MMS_042350]How to send-receive SMS text messages using Westermo modem.zip

    AB PLC例程代码项目案例 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!

    OIF_IEEE802.3_liaison_19OCt09.pdf

    OIF_IEEE802.3_liaison_19OCt09

    SerU,做网络安全FTP内容的实验必备

    做网络安全FTP内容的实验必备

    nagarajan_01_1107.pdf

    nagarajan_01_1107

    [AB PLC例程源码][MMS_043879]Programming in SFC and ST Language.zip

    AB PLC例程代码项目案例 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!

    mellitz_3cd_01_0318.pdf

    mellitz_3cd_01_0318

    PyQt6实战派 配套代码

    PyQt6实战派 配套代码

    陕西省省级非物质文化遗产民俗经纬度数据统计表

    陕西省省级非物质文化遗产经纬度数据统计表 统计内容包含以下字段: 1. 项目名称 2. 遗产类别 3. 入选批次 4. 所属地区 5. 申报地区/单位 6. 地理经度 7. 地理纬度 该统计表系统记录了陕西省省级非物质文化遗产的地理空间信息,为文化遗产的数字化保护与研究工作提供了重要的数据支撑。

    ran_3ck_02a_0918.pdf

    ran_3ck_02a_0918

    毕业设计-基于springboot+vue开发的汽车租赁管理系统【源码+sql+可运行】50308.zip

    毕业设计_基于springboot+vue开发的汽车租赁管理系统【源码+sql+可运行】【50308】.zip 全部代码均可运行,亲测可用,尽我所能,为你服务; 1.代码压缩包内容 代码:springboo后端代码+vue前端页面代码; 脚本:数据库SQL脚本 效果图:运行结果请看资源详情效果图 2.环境准备: - JDK1.8+ - maven3.6+ - nodejs14+ - mysql5.6+ - redis 3.技术栈 - 后台:springboot+mybatisPlus+Shiro - 前台:vue+iview+Vuex+Axios - 开发工具: idea、navicate 4.功能列表 - 系统设置:用户管理、角色管理、资源管理、系统日志 - 业务管理:汽车管理、客户管理、租赁订单 3.运行步骤: 步骤一:修改数据库连接信息(ip、port修改) 步骤二:找到启动类xxxApplication启动 4.若不会,可私信博主!!!

    Runcorder - 跑步训练管理系统

    # Runcorder - 跑步训练管理系统 Runcorder 是一款专为跑步爱好者、马拉松运动员及高校体育生设计的本地化跑步训练管理工具,基于 Python 开发,结合 Tkinter 图形界面与强大的数据处理能力,为用户提供从训练记录到数据分析的全方位支持。无论是初学者还是专业跑者,Runcorder 都能帮助你科学规划训练、精准追踪进度,并通过可视化图表直观呈现训练成果,让你的跑步训练更智能、更高效! - **多用户管理**:支持创建、加载和删除用户档案,每个用户的数据独立存储,确保隐私与安全。 - **科学训练记录**:全维度记录跑步数据,包括日期、里程、配速、自评和晨跑标记,支持智能输入校验,避免数据错误。 - **多维数据分析**:通过动态可视化图表展示跑步里程趋势、平均配速曲线,支持自定义 Y 轴范围,帮助用户深入理解训练效果。 - **高阶功能**:提供 4 种科学训练模式(有氧/无氧/混合),支持历史记录修改与删除,数据以 JSON 格式持久化存储,跨平台兼容。

    paatzsch_01_0708.pdf

    paatzsch_01_0708

Global site tag (gtag.js) - Google Analytics