java Óë c# 3des ¼Ó½âÃÜ
java Óë c# 3des ¼Ó½âÃÜ
Ö÷Òª²îÒìÈçÏ£º
1¡¢ ¶ÔÓÚ´ý¼ÓÃܽâÃܵÄÊý¾Ý£¬¸÷×ÔµÄÌî³äģʽ²»Ò»Ñù
C#µÄģʽÓУºANSIX923¡¢ISO10126¡¢None¡¢PKCS7¡¢Zero£¬¶øJavaÓУºNoPadding¡¢PKCS5Padding¡¢SSL3Padding
2¡¢ ¸÷×ÔĬÈϵÄ3DESʵÏÖ£¬Ä£Ê½ºÍÌî³ä·½Ê½²»Ò»Ñù
C#µÄĬÈÏģʽΪCBC,ĬÈÏÌî³ä·½Ê½ÎªPKCS7; javaµÄĬÈÏģʽΪECB£¬Ä¬ÈÏÌî³ä·½Ê½ÎªPKCS5Padding
3¡¢ ¸÷×ÔµÄkeyµÄsize²»Ò»Ñù
C#ÖÐkeyµÄsizeΪ16ºÍ24¾ù¿É£»javaÖÐÒªÇókeyµÄsize±ØÐëΪ24£»¶ÔÓÚCBCģʽϵÄÏòÁ¿ivµÄsizeÁ½Õß¾ùÒªÇó±ØÐëΪ8
·¿´ÁË3DESµÄÔÀí£º
DESÖ÷Òª²ÉÓÃÌæ»»ºÍÒÆλµÄ·½·¨,ÓÃ56λÃÜÔ¿¶Ô64λ¶þ½øÖÆÊý¾Ý¿é½øÐмÓÃÜ,ÿ´Î¼ÓÃܿɶÔ64λµÄÊäÈëÊý¾Ý½øÐÐ16ÂÖ±àÂë,
¾Ò»ÏµÁÐÌæ»»ºÍÒÆλºó,ÊäÈëµÄ64λת»»³É°²È«²»Í¬µÄ64µÄÊä³öÊý¾Ý
.
3DES:ÊÇÔÚDESµÄ»ù´¡ÉϲÉÓÃÈýÖØDES,¼´ÓÃÁ½¸ö56λµÄÃÜÔ¿K1,K2,·¢ËÍ·½ÓÃK1¼ÓÃÜ,K2½âÃÜ,ÔÙʹÓÃK1¼ÓÃÜ.½ÓÊÕ·½Ê¹ÓÃK1½âÃÜ,K2¼ÓÃÜ,ÔÙʹÓÃK1½âÃÜ,
ÆäЧ¹ûÏ൱ÓÚÃÜÔ¿³¤¶È¼Ó±¶.
ÓÚÊdz¢ÊÔÔÚjavaÖУ¬¶Ôkey½øÐв¹Î»£¬¼´ÓÃÇ°8¸ö×Ö½Ú×÷Ϊbyte[24] ÖеÄbyte[16]~byte[23];·¢ÏÖÓëc#ÖмÓÃܵĽá¹ûÏàͬ£¡ÓÚÊǴ󵨼ÙÉèC#ÖпÉÄÜÊǼì²ékeyµÄsizeΪ16µÄʱºò
×Ô¶¯½«Ç°8¸ö×Ö½Ú×÷Ϊk3½øÐÐÁ˲¹Î»£¬¶øjavaûÓÐʵÏÖÕâÒ»µã£¨ÒòΪjavaµÄ3DESËã·¨ÖÐÇ¿ÖÆÒªÇókeyµÄsize±ØÐëΪ24£©¡£ÕâÑùµÄÇé¿öÏ£¬¿ÉÄܾÍÊÇ·¢ËÍ·½ÓÃk1¼ÓÃÜ¡¢k2½âÃÜ¡¢k3ÔÙ¼ÓÃÜ£»½ÓÊÜ·½k3½âÃÜ¡¢k2¼ÓÃÜ¡¢ÔÙk1½âÃÜÀ´ÊµÏÖ¡£
×îÖÕ¾¹ý±àÂëÑéÖ¤£¬È·ÈÏkey´óСΪ24ʱ£¬javaºÍc#µÄ¼ÓÃܽâÃܽá¹ûÏàÒ»Ö¡£
JavaÖÐʵÏÖʱ£¬Ö»Òª×¢Òâ¶Ô´óС²»×ã24µÄkey½øÐв¹Î»£¬ºÍ²ÉÓÃCBCģʽ£¬Ìî³äģʽΪPKCS5Padding¼´¿É¡£
public class CDES {
public static byte[] encrypt(String sKey, byte[] bIV, byte[] bPlainText, int nOffset, int nSize)
throws Exception {
byte[] bKey = buildKey(sKey);
byte[] bInput = buildInput(nSize, bPlainText, nOffset);
byte[] bResult = encrypt(bIV, bKey, bInput);
return bResult;
}
public static byte[] decrypt(String sKey, byte[] bIV, byte[] bCipherText)
throws Exception {
byte[] bKey = buildKey(sKey);
SecretKey securekey = buildSecretKey(bKey);
IvParameterSpec iv = new IvParameterSpec(bIV);
Ciph
Ïà¹ØÎĵµ£º
À´Ô´£ºhttp://www.blogjava.net/lcs868/archive/2008/12/16/246644.html
ÓÃjavaʵÏÖ¶Ô´¿ÕæIPÊý¾Ý¿âµÄ²éѯ£¬Ê×Ïȵ½ÍøÉÏÏÂÔØQQwry.daÎļþ£¬¶ÁÈ¡´úÂëÈçÏ£º
1.IP¼Ç¼ʵÌåÀà package com.guess.tools; /** *
* Ò»ÌõIP·¶Î§¼Ç¼£¬²»½ö°üÀ¨¹ú¼ÒºÍÇøÓò£¬ ......
SQLiteÊÇÒ»¸ö¾«ÇɵÄÇáÁ¿¼¶Êý¾Ý¿â£¬½ñÌìÖÕÓÚ»ù±¾ÕÆÎÕÁËÈçºÎÓÃC#²Ù×÷SQLiteÊý¾Ý¿â¡£¸ù¾ÝÍøÓÑÃǵľÑ飬ÖÁÉÙÓÐÁ½ÖÖ·½·¨¿ÉÒÔ×öµ½SQLiteµÄµ÷Óã¬Ò»ÖÖÊǵ÷ÓÃsqlite3.dll£¬Ò»ÖÖÊÇÓÃSystem.Data.SQLite£¬¼´sqlite.ADO.NET,ÊÇרΪC sharp·â×°µÄsqliteº¯Êý£¬ºÜÁ÷ÐС£
¼òµ¥Ãè ......
ÎÄ˼ÐÅÏ¢¼¼ÊõÓÐÏÞ¹«Ë¾www.vanceinfo.com£¨Å¦½»ËùÉÏÊдúÂ룺VIT£©³ÉÁ¢ÓÚ1995Ä꣬ÊÇÒ»¼ÒÐÅÏ¢¼¼Êõ·þÎñÌṩÉ̼°ÔÚÖйú¾ÓÁìÏȵØλµÄÀë°¶Èí¼þ¿ª·¢¹«Ë¾Ö®Ò»¡£ÎÄ˼ÊǵÚÒ»¼ÒÔÚŦԼ¹ÉƱ½»Ò×ËùÉÏÊеÄÖйúÈí¼þ·þÎñÍâ°üÆóÒµ¡£¾Ý¹ú¼ÊÊý¾Ý¹«Ë¾(IDC)µÄͳ¼Æ, ÒÔ2007ÄêÏúÊÛ¶îºâÁ¿, ÎÄ˼ÐÅÏ¢¼¼ÊõÔÚΪŷÃÀÊг¡ÌṩÀë°¶Èí¼þ¿ª·¢ÐÐÒµÖÐλ¾ÓÖйúµÚÒ ......
Óà Java ½âÃÜ C# ¼ÓÃܵÄÊý¾Ý(DES)
[ÔÎĵØÖ·£ºhttp://yidinghe.cnblogs.com/articles/449212.html]
½ñÌìÅöÉÏÒ»¼þÁîÎÒÍ·´óµÄÊÂÇé¡£ÎÒÃǵÄϵͳҪºÍÒ»¸öÍⲿϵͳ½øÐÐͨѶ£¬´«Ê䷽ʽÊDzÉÓà DES Ëã·¨¶ÔÏûÏ¢½øÐмÓÃÜ£¬ÔÙÓà BASE64 ±àÂë¡£²»¹ý¶Ô·½ÏµÍ³ÊÇÓà C# дµÄ¡£Æ½Ì¨²»Ò»Ñù£¬ÓÚÊÇÎҺͶÔÃæµÄÀÏÐÖÏȲâÊÔһϼÓÃܽâÃÜ¡£ ......