`
心-云
  • 浏览: 21279 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

java基于des3的加密解密

    博客分类:
  • java
阅读更多
       年末,项目没那么紧了,能收钱的都已经收了,收不了的也没戏了,so,悠闲的日子又来了。闲的蛋疼,于是就研究了下公司某个证书,看看是否能破解,于是乎,就出来了这篇东西。话不多扯,直接上主菜:

public class Test {
	private DES3_CBC_CTX_2 _ctx = new DES3_CBC_CTX_2();
	
	private final static long[][] Spbox = {
		{0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
		0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
		0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
		0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
		0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
		0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
		0x00010004L, 0x01004004L, 0x01000004L, 0x00010004L,
		0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
		0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
		0x01010400L, 0x01000400L, 0x01000000L, 0x00000400L,
		0x01010004L, 0x00010000L, 0x00010400L, 0x01000804L,
		0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
		0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
		0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
		0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
		0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L},
		
		{0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
		0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
		0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
		0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
		0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
		0x80001000L, 0x00008000L, 0x00108020L, 0x80100000L,
		0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
		0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
		0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
		0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
		0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
		0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
		0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
		0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
		0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
		0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L},
		
		{0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
		0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
		0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
		0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
		0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
		0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
		0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
		0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
		0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
		0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
		0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
		0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
		0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
		0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
		0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
		0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L},
		
		{0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
		0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
		0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
		0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
		0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
		0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
		0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
		0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
		0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
		0x00000081L, 0x00000000L, 0x00002000L, 0x00802000L,
		0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
		0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
		0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
		0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
		0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
		0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L},
		
		{0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
		0x00080000L, 0x02000100L, 0x40000000L, 0x02080000L,
		0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
		0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
		0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
		0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
		0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
		0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
		0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
		0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
		0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
		0x40080100L, 0x00000100L, 0x02000800L, 0x42080000L,
		0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
		0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
		0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
		0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L},
		
		{0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
		0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
		0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
		0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
		0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
		0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
		0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
		0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
		0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
		0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
		0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
		0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
		0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
		0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
		0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
		0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L},
		
		{0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
		0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
		0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
		0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
		0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
		0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
		0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
		0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
		0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
		0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
		0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
		0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
		0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
		0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
		0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
		0x04000002L, 0x04010800L, 0x00000800L, 0x00200002L},
		
		{0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
		0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
		0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
		0x10041000L, 0x00041040L, 0x00001000L, 0x00800040L,
		0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
		0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
		0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
		0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
		0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
		0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
		0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
		0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
		0x00002000L, 0x10041040L, 0x00040040L, 0x10000040L,
		0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
		0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
		0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L}
	};
	
	  private static final long[][] keysD = { 
		  { 1060312887L, 1061105191L, 1044324135L, 1060972330L, 1061101340L, 925840175L, 792673310L, 1061104411L, 925842479L, 1061108237L, 1061106959L, 1027417653L, 1059006254L, 926889223L, 792669726L, 1061106751L, 1060974120L, 1061108539L, 1061108795L, 792401721L, 1061107498L, 1061031740L, 993736253L, 1061094702L, 1060978460L, 994000168L, 1061040669L, 792674075L, 1061108535L, 1044261913L, 926882085L, 524226367L }, 
		  { 1058479411L, 1061095982L, 658445333L, 1061105437L, 1061108246L, 926628648L, 1061108284L, 1059915563L, 910106408L, 1059005758L, 524236071L, 524227898L, 1027023145L, 1060051769L, 1044331577L, 1043807028L, 1060713992L, 1061109007L, 993994014L, 1059989292L, 1044327983L, 792658725L, 1060977706L, 523972147L, 960437564L, 1061106203L, 1061105413L, 1058485018L, 524228877L, 1060839206L, 992941871L, 1060973577L }, 
		  { 792080191L, 1061103884L, 1061100860L, 1060969759L, 926891567L, 926628410L, 792672573L, 1060975413L, 992945446L, 926887739L, 792534575L, 1027552559L, 1057963802L, 792667965L, 1061106238L, 1027480335L, 1060975931L, 524238622L, 977223465L, 792660031L, 1060977983L, 1059985186L, 1060842252L, 792674110L, 926891573L, 993928987L, 1060773690L, 1060978217L, 1061107231L, 842993463L, 926881555L, 1057960766L } 
		};

	  private static final long[][] keysE = { 
		  { 926881555L, 1057960766L, 1061107231L, 842993463L, 1060773690L, 1060978217L, 926891573L, 993928987L, 1060842252L, 792674110L, 1060977983L, 1059985186L, 977223465L, 792660031L, 1060975931L, 524238622L, 1061106238L, 1027480335L, 1057963802L, 792667965L, 792534575L, 1027552559L, 992945446L, 926887739L, 792672573L, 1060975413L, 926891567L, 926628410L, 1061100860L, 1060969759L, 792080191L, 1061103884L }, 
		  { 992941871L, 1060973577L, 524228877L, 1060839206L, 1061105413L, 1058485018L, 960437564L, 1061106203L, 1060977706L, 523972147L, 1044327983L, 792658725L, 993994014L, 1059989292L, 1060713992L, 1061109007L, 1044331577L, 1043807028L, 1027023145L, 1060051769L, 524236071L, 524227898L, 910106408L, 1059005758L, 1061108284L, 1059915563L, 1061108246L, 926628648L, 658445333L, 1061105437L, 1058479411L, 1061095982L }, 
		  { 926882085L, 524226367L, 1061108535L, 1044261913L, 1061040669L, 792674075L, 1060978460L, 994000168L, 993736253L, 1061094702L, 1061107498L, 1061031740L, 1061108795L, 792401721L, 1060974120L, 1061108539L, 792669726L, 1061106751L, 1059006254L, 926889223L, 1061106959L, 1027417653L, 925842479L, 1061108237L, 792673310L, 1061104411L, 1061101340L, 925840175L, 1044324135L, 1060972330L, 1060312887L, 1061105191L } 
	  	};
	
	private long F(long l, long r, long[]key, int keyStart)
	{
		
		long work = ((r >> 4) | ((r << 28)&0xFFFFFFFFL)) ^ key[keyStart];
		l ^= Spbox[6][(int)(work & 0x3f)];
		l ^= Spbox[4][(int)((work >> 8) & 0x3f)];
		l ^= Spbox[2][(int)((work >> 16) & 0x3f)];
		l ^= Spbox[0][(int)((work >> 24) & 0x3f)];
		work = r ^ key[keyStart+1];
		l ^= Spbox[7][(int)(work & 0x3f)];
		l ^= Spbox[5][(int)((work >> 8) & 0x3f)];
		l ^= Spbox[3][(int)((work >> 16) & 0x3f)];
		l ^= Spbox[1][(int)((work >> 24) & 0x3f)];
		return l;
	}
	
	private static void cookey(long[] subkeys, long[] kn, int encrypt){
		long[]  raw;
		int increment;
		int i;

		raw = kn;
		int cookIndex =  encrypt!=0 ? 0 : 30;
		increment = encrypt!=0 ? 1 : -3;

		for (i = 0; i < 16; i++) {

			subkeys[cookIndex]    = ( (raw[i] & 0x00fc0000L) << 6)&0xFFFFFFFFL;
			subkeys[cookIndex]   |= ( (raw[i] & 0x00000fc0L) << 10)&0xFFFFFFFFL;
			subkeys[cookIndex]   |= (raw[i+1] & 0x00fc0000L) >> 10;
			subkeys[cookIndex++] |= (raw[i+1] & 0x00000fc0L) >> 6;
			subkeys[cookIndex]    = ( (raw[i] & 0x0003f000L) << 12)&0xFFFFFFFFL;
			subkeys[cookIndex]   |= ( (raw[i] & 0x0000003fL) << 16)&0xFFFFFFFFL;
			subkeys[cookIndex]   |= (raw[i+1] & 0x0003f000L) >> 4;
			subkeys[cookIndex]   |= (raw[i+1] & 0x0000003fL);
			cookIndex += increment;
		}
		
	}
	

	public void DES3_CBCInit(int type)
	{
		int encrypt = type;
		
		this._ctx.iv[0] = 4208289545L;
		_ctx.iv[1] = 1326297792L;

		_ctx.originalIV[0] = 4208289545L;
		_ctx.originalIV[1] = 1326297792L;
		_ctx.encrypt = encrypt;
		_ctx.subkeys = keysD;
		if(encrypt == 1)   //如果是加密 
			_ctx.subkeys = keysE;
		else  //如果是解密
			_ctx.subkeys = keysD;

	}	
	
	private void scrunch(long[] into,  char[] outof, int outofStart){
		int i = outofStart;
		into[0]    = ( (outof[i++] & 0xffL) << 24)&0xFFFFFFFFL;
		into[0]   |= ( ( (outof[i++] & 0xffL) << 16)&0xFFFFFFFFL);
		into[0]   |= ( ( (outof[i++] & 0xffL) << 8)&0xFFFFFFFFL);
		into[0] |=  (outof[i++] & 0xffL);
		into[1]    = ( (outof[i++] & 0xffL) << 24)&0xFFFFFFFFL;
		into[1]   |= ( ( (outof[i++] & 0xffL) << 16)&0xFFFFFFFFL);
		into[1]   |= ( ( (outof[i++] & 0xffL) << 8)&0xFFFFFFFFL);
		into[1]   |= (outof[i]   & 0xffL);
	}	
	
	private void unscrunch(char[] into,int intoStart, long[] outof){
		int i=intoStart;
		into[i++] = (char)((outof[0] >> 24) & 0xffL);
		into[i++] = (char)((outof[0] >> 16) & 0xffL);
		into[i++] = (char)((outof[0] >>  8) & 0xffL);
		into[i++] = (char)( outof[0]      & 0xffL);
		into[i++] = (char)((outof[1] >> 24) & 0xffL);
		into[i++] = (char)((outof[1] >> 16) & 0xffL);
		into[i++] = (char)((outof[1] >>  8) & 0xffL);
		into[i]   = (char)( outof[1]        & 0xffL);
	}	
	
	public byte[] DES3_CBCUpdate(byte[] input)
	{
		 int len = ((input.length+7)/8)*8;
		long[] inputBlock=new long[2], work=new long[2];


		if(len % 8 != 0)                  /* length check */
			return new byte[0];

		int nCount = len/8;
		char[] chInput = new char[len];
		for(int i=0; i< input.length; i++)
			chInput[i] = (char)(0x0FF & input[i]);
		
		char[][] chOutput = new char[nCount][8];
		
		for(int i = 0; i < nCount; i++) {
			scrunch(inputBlock, chInput,8*i);

			/* Chain if encrypting. */
			if(_ctx.encrypt == 0) {
				work[0] = inputBlock[0];
				work[1] = inputBlock[1];
			}
			else {
				work[0] = inputBlock[0] ^ _ctx.iv[0];
				work[1] = inputBlock[1] ^ _ctx.iv[1];
			}

			desfunc(work, _ctx.subkeys[0]);
			desfunc(work, _ctx.subkeys[1]);
			desfunc(work, _ctx.subkeys[2]);

			/* Chain if decrypting, then update IV. */
			if(_ctx.encrypt == 0) {
				work[0] ^= _ctx.iv[0];
				work[1] ^= _ctx.iv[1];
				_ctx.iv[0] = inputBlock[0];
				_ctx.iv[1] = inputBlock[1];
			}
			else {
				_ctx.iv[0] = work[0];
				_ctx.iv[1] = work[1];
			}
			unscrunch(chOutput[i],0, work);
		}
		int size = nCount*8;
		byte[] output = new byte[size];
		int index = 0;
		for(int i=0; i< nCount; i++)
		{
			output[index++] = (byte)chOutput[i][0];
			output[index++] = (byte)chOutput[i][1];
			output[index++] = (byte)chOutput[i][2];
			output[index++] = (byte)chOutput[i][3];
			output[index++] = (byte)chOutput[i][4];
			output[index++] = (byte)chOutput[i][5];
			output[index++] = (byte)chOutput[i][6];
			output[index++] = (byte)chOutput[i][7];
		}
		return output;
	}
	

	void desfunc(long[] block, long[] ks){
		long left,right,work;
	
		left = block[0];
		right = block[1];
	
		work = ((left >> 4) ^ right) & 0x0f0f0f0f;
		right ^= work;
		left ^= (work << 4)&0xFFFFFFFFL;
		work = ((left >> 16) ^ right) & 0xffff;
		right ^= work;
		left ^= (work << 16)&0xFFFFFFFFL;
		work = ((right >> 2) ^ left) & 0x33333333;
		left ^= work;
		right ^= (work << 2)&0xFFFFFFFFL;
		work = ((right >> 8) ^ left) & 0xff00ff;
		left ^= work;
		right ^= (work << 8)&0xFFFFFFFFL;
		right = ( (right << 1)&0xFFFFFFFFL) | (right >> 31);
		work = (left ^ right) & 0xaaaaaaaa;
		left ^= work;
		right ^= work;
		left = ( (left << 1)&0xFFFFFFFFL) | (left >> 31);
	
		/* Now do the 16 rounds */
		left = F(left,right,ks,0);
	
		right = F(right,left,ks,2);
		left = F(left,right,ks,4);
		right = F(right,left,ks,6);
		left = F(left,right,ks,8);
		right = F(right,left,ks,10);
		left = F(left,right,ks,12);
		right = F(right,left,ks,14);
		left = F(left,right,ks,16);
		right = F(right,left,ks,18);
		left = F(left,right,ks,20);
		right = F(right,left,ks,22);
		left = F(left,right,ks,24);
		right = F(right,left,ks,26);
		left = F(left,right,ks,28);
		right = F(right,left,ks,30);
	
	
		right = ((right << 31)&0xFFFFFFFFL) | (right >> 1);
		work = (left ^ right) & 0xaaaaaaaa;
		left ^= work;
		right ^= work;
		left = (left >> 1) | ((left  << 31)&0xFFFFFFFFL);
		work = ((left >> 8) ^ right) & 0xff00ff;
		right ^= work;
		left ^= (work << 8)&0xFFFFFFFFL;
		work = ((left >> 2) ^ right) & 0x33333333;
		right ^= work;
		left ^= (work << 2)&0xFFFFFFFFL;
		work = ((right >> 16) ^ left) & 0xffff;
		left ^= work;
		right ^= (work << 16)&0xFFFFFFFFL;
		work = ((right >> 4) ^ left) & 0x0f0f0f0f;
		left ^= work;
		right ^= (work << 4)&0xFFFFFFFFL;
	
		block[0] = right;
		block[1] = left;
	}
	
	public static void main(String[] args)
	{

		String str = "adads343534/$90900"; 
		Test des = new Test();			
		des.DES3_CBCInit(0);
		byte[] result = des.DES3_CBCUpdate(str.getBytes());
		des.DES3_CBCInit(1);
		byte[] result2 = des.DES3_CBCUpdate(result);
		System.out.println("====加密========"+new String(result));
		System.out.println("====解密========"+new String(result2));
	}
}

class DES3_CBC_CTX_2{
	  long[][] subkeys = new long[3][32];      
	  long[] iv = new long[2];                                      
	  long[] originalIV = new long [2];                        
	  int encrypt;   	
}
1
0
分享到:
评论
1 楼 hangzhoujava 2016-01-04  
好东西啊 

相关推荐

    Java中3DES加密解密示例(封装byte数组16进制互转)

    Java 中的 3DES 加密解密示例(封装 byte 数组和 16 进制字符串互转) 在 Java 中,3DES 加密是一种常用的加密算法,它可以将明文数据转换为密文数据,以保护数据的安全性。在本示例中,我们将展示如何使用 3DES ...

    java和javascript之间的DES加密解密

    Java和JavaScript之间的DES加密解密是信息安全领域中的一个重要话题,主要涉及到数据的保护和通信的安全。DES(Data Encryption Standard)是一种古老的对称加密算法,尽管它在安全性上已不被视为最佳选择,但在某些...

    java 3des加密、解密工具类

    java 3des加密、解密工具类 java的3DES加密/解密

    java版DES通用加密解密

    java版DES通用加密解密,使用JDK通用类,所以支持sun JDK和ibm JDK等

    java的DES加密解密

    java的DES加密解密:用于密码在数据库的加密,解码类

    Des.JAVA.rar_DES.java_DES加密_java DES 128bit_java des_加密解密

    总的来说,这个压缩包提供了一套完整的Java实现的DES加密解密工具,包括核心算法、子密钥生成、文件加密等功能,对于学习DES算法和在Java项目中使用DES加密的开发者来说,是一个非常实用的资源。使用者可以通过阅读...

    java_DES加密解密源码.rar_DES加密_des_java DES_java des_加密 解密

    Java实现des加密解密算法,des加密解密算法

    java-des.zip_Des加密解密_des_java des_java 加密解密

    des加密解密算法,通过DES加密解密实现一个String字符串的加密和解密.

    JavaDES通过秘钥加密解密Demo

    JavaDES通过秘钥加密解密Demo

    JAVA实现3DES加密解密

    总的来说,通过Java实现3DES加密解密,我们需要理解加密算法的基本原理,熟悉Java的相关加密库,并掌握如何生成和使用密钥。在实际开发中,确保数据的安全性至关重要,因此正确地使用加密技术是每个IT专业人员必备的...

    des加密解密java实现版本

    本篇文章将详细阐述DES加密解密的Java实现过程。 首先,我们需要了解DES算法的基本原理。DES是一种块密码,它将明文数据分成64位的数据块进行处理,其中包含56位的密钥。通过一系列复杂的置换和代换操作,将明文块...

    JAVA_DES3加密算法.doc

    在给定的代码中,展示了如何在Java中实现3DES加密和解密的过程。 首先,3DES加密过程通常包括以下步骤: 1. **生成密钥**:在Java中,密钥通常通过`KeyGenerator`类生成。在提供的代码中,密钥是通过`getKey()`...

    java php DES 加密解密

    在Java中,DES加密解密主要通过`javax.crypto`包中的类来实现。首先,我们需要一个密钥,通常是8字节的字节数组。然后,使用`KeyGenerator`生成一个DES密钥。接下来,创建`Cipher`对象并初始化它,根据需要进行加密...

    实现使用3des在页面js加密,后台java解密

    本篇将详细介绍如何在网页前端使用JavaScript进行3DES加密,并在后端Java环境中进行解密。 一、3DES加密原理 3DES是DES的加强版,它使用了3个不同的56位密钥,通过3次独立的DES加密过程来提高安全性。具体流程如下...

    小程序+java后端统一 des 加密解密

    总的来说,小程序与Java后端使用DES加密解密是数据安全的一种基础实践,但考虑到当前的网络安全需求,可能需要结合其他更强的加密技术以及安全策略来提升整体的安全水平。在实际应用中,还需要关注相关的法律法规,...

    java和C#通用des3加解密

    标题中的“java和C#通用des3加解密”指的是在Java和C#这两种不同的编程语言中实现DES(Data Encryption Standard)的加强版——3DES(Triple DES)加解密算法。3DES是一种广泛使用的对称加密算法,通过三次应用DES的...

    des加密算法(js+java)js加密 java解密

    des加密算法(js+java)加密与解密结果相同 包含三个文件 : des.js des.html ,用于实现前端脚本的加密与解密 des.java 用于后台的加密解密操作; 项目中正好用到,已经过验证,两个加密解密结果相同,分享给...

    3DES加密解密java版+js版

    在Java和JavaScript中实现3DES加密和解密,主要涉及以下几个关键知识点: 1. **密钥生成**:3DES需要一个168位的密钥,但通常我们提供的是一个128位或更短的密钥。Java中的`javax.crypto.SecretKeyFactory`和`javax...

    3DES加密解密

    在压缩包中,"DES3.jar"可能是一个包含3DES加密解密功能的Java库文件,可以被其他Java项目导入并直接使用。"使用说明.txt"则提供了关于如何使用这个库以及调用相关加密解密方法的指南。在实际操作中,开发者会按照这...

    实验一 基于DES加密的TCP聊天程序1

    在本文中,我们将深入探讨基于DES加密的TCP聊天程序的实现,以及DES算法和TCP协议的相关知识。DES(Data Encryption Standard)是一种广泛应用的对称加密算法,它的历史可以追溯到20世纪70年代,由IBM的Lucifer算法...

Global site tag (gtag.js) - Google Analytics