Óà Java ½âÃÜ C# ¼ÓÃܵÄÊý¾Ý(DES)
Óà Java ½âÃÜ C# ¼ÓÃܵÄÊý¾Ý(DES)
[ÔÎĵØÖ·£ºhttp://yidinghe.cnblogs.com/articles/449212.html]
½ñÌìÅöÉÏÒ»¼þÁîÎÒÍ·´óµÄÊÂÇé¡£ÎÒÃǵÄϵͳҪºÍÒ»¸öÍⲿϵͳ½øÐÐͨѶ£¬´«Ê䷽ʽÊDzÉÓà DES Ëã·¨¶ÔÏûÏ¢½øÐмÓÃÜ£¬ÔÙÓà BASE64 ±àÂë¡£²»¹ý¶Ô·½ÏµÍ³ÊÇÓà C# дµÄ¡£Æ½Ì¨²»Ò»Ñù£¬ÓÚÊÇÎҺͶÔÃæµÄÀÏÐÖÏȲâÊÔһϼÓÃܽâÃÜ¡£ÕâÒ»²âÊÔÎÊÌâ¾ÍÀ´ÁË¡£Á½±ß²ÉÓÃͬÑùµÄÃÜÔ¿£¬¶Ôͬһ¸ö×Ö·û´®¼ÓÃܳöÀ´µÄ½á¹û²»Ò»Ñù¡£Ôõô°ìÄØ£¿ÎÒÏÈ°ÑËûÄDZߵĴúÂëÒª¹ýÀ´ÁË£¬ËûÊÇÕâÑùдµÄ(C#)£º
public static string Encrypt(string message, string key)
{
DES des = new DESCryptoServiceProvider();
des.Key = Encoding.UTF8.GetBytes(key);
des.IV = Encoding.UTF8.GetBytes(key);
byte[] bytes = Encoding.UTF8.GetBytes(message);
byte[] resultBytes = des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
return Convert.ToBase64String(resultBytes);
}
¶øÎÒÕâ±ßÄØ£¬ÊÇÓà Java ÕâÑùдµÄ£¨½ö½ö¼ÓÃܵ½×Ö½Ú´®£¬BASE64 ±àÂëÊÇÔÚÁíÒ»¸öÀàÀ£º
public static byte[] desEncrypt(String message, String key) throws Exception {
Cipher cipher = Cipher.getInstance("DES");
DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("UTF-8"));
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey secretKey = keyFactory.generateSecret
Ïà¹ØÎĵµ£º
һЩÆóÒµÔÚÕÐƸ³ÌÐòÔ±µÄʱºò£¬×Ü»áÌØÒâÌá³öÒ»¸öÒªÇ󣬼´ÒªÇó¾ßÓÐÁ¼ºÃµÄ±àÂë¹æ·¶¡£È·ÊµÏÖÔÚ³ÌÐò¿ª·¢ÈËÔ±ÒѾ²»ÔÚÊǵ¥Ç¹Æ¥ÂíµÄµ¥¸É£¬¶øÊǽ²¾¿ÍÅÌå×÷Õ½¡£´Ëʱ¾ÍÒªÇóÍŶÓÄڵijËÔ±¶¼¿ÉÄܹ»ã¡ÊØ´úÂëµÄ±àд¹æ·¶£¬Õâ¶ÔÓÚ³ËÔ±Ö®¼ä¹²Ïí´úÂë¡¢ÅÅ´íµÈ×÷Òµ¶¼¾ßÓзdz£ÏÖʵµÄÒâÒå¡£ÕâÔÚJavaÓïÑÔÖе±È»Ò²²»ÀýÍâ¡£±ÊÕß½èÕâ´Î»ú»á£¬¾Í¸ú´ó¼Ò·Ö ......
À´Ô´£ºhttp://www.blogjava.net/lcs868/archive/2008/12/16/246644.html
ÓÃjavaʵÏÖ¶Ô´¿ÕæIPÊý¾Ý¿âµÄ²éѯ£¬Ê×Ïȵ½ÍøÉÏÏÂÔØQQwry.daÎļþ£¬¶ÁÈ¡´úÂëÈçÏ£º 1.IP¼Ç¼ʵÌåÀà package com.guess.tools; /** *
* Ò»ÌõIP·¶Î§¼Ç¼£¬²»½ö°üÀ¨¹ú¼ÒºÍÇøÓò£¬Ò²°üÀ¨ÆðʼIPºÍ½áÊøIP * *
* @author swal ......
´ËÎÄÖеĴúÂëÖ÷ÒªÁгöÁ¬½ÓÊý¾Ý¿âµÄ¹Ø¼ü´úÂ룬ÆäËû·ÃÎÊÊý¾Ý¿â´úÂëÊ¡ÂÔ
¡¡¡¡1¡¢Oracle8/8i/9iÊý¾Ý¿â£¨thinģʽ£©
¡¡¡¡¡¡¡¡Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
¡¡¡¡¡¡¡¡String url="jdbc:oracle:thin:@localhost:1521:orcl";
¡¡¡¡¡¡¡¡//orclΪÊý¾Ý¿âµÄSID
¡¡¡¡¡¡¡¡String user="test";
¡ ......
SQLiteÊÇÒ»¸ö¾«ÇɵÄÇáÁ¿¼¶Êý¾Ý¿â£¬½ñÌìÖÕÓÚ»ù±¾ÕÆÎÕÁËÈçºÎÓÃC#²Ù×÷SQLiteÊý¾Ý¿â¡£¸ù¾ÝÍøÓÑÃǵľÑ飬ÖÁÉÙÓÐÁ½ÖÖ·½·¨¿ÉÒÔ×öµ½SQLiteµÄµ÷Óã¬Ò»ÖÖÊǵ÷ÓÃsqlite3.dll£¬Ò»ÖÖÊÇÓÃSystem.Data.SQLite£¬¼´sqlite.ADO.NET,ÊÇרΪC sharp·â×°µÄsqliteº¯Êý£¬ºÜÁ÷ÐС£
¼òµ¥Ãè ......
Ò»£ºC# Á¬½ÓSQLÊý¾Ý¿â
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Server=myServerAddress;Database=myDataBase;User ID=myUse ......