TEA¼ÓÃÜËã·¨java°æ
Õâ¸öËã·¨¼òµ¥,¶øÇÒЧÂʸß,ÿ´Î¿ÉÒÔ²Ù×÷8¸ö×Ö½ÚµÄÊý¾Ý,¼ÓÃܽâÃܵÄKEYΪ16×Ö½Ú,¼´°üº¬4¸öintÊý¾ÝµÄintÐÍÊý×é,¼ÓÃÜÂÖÊýӦΪ8µÄ±¶Êý,Ò»°ã±È½Ï³£ÓõÄÂÖÊýΪ64,32,16,ÍÆ¼öÓÃ64ÂÖ.
Ô´´úÂëÈçÏÂ:
/** *//**
* TeaËã·¨
* ÿ´Î²Ù×÷¿ÉÒÔ´¦Àí8¸ö×Ö½ÚÊý¾Ý
* KEYΪ16×Ö½Ú,ӦΪ°üº¬4¸öintÐÍÊýµÄint[]£¬Ò»¸öintΪ4¸ö×Ö½Ú
* ¼ÓÃܽâÃÜÂÖÊýӦΪ8µÄ±¶Êý£¬ÍƼö¼ÓÃÜÂÖÊýΪ64ÂÖ
* */
public class Tea {
//¼ÓÃÜ
public byte[] encrypt(byte[] content, int offset, int[] key, int times){//timesΪ¼ÓÃÜÂÖÊý
int[] tempInt = byteToInt(content, offset);
int y = tempInt[0], z = tempInt[1], sum = 0, i;
int delta=0x9e3779b9; //ÕâÊÇËã·¨±ê×¼¸øµÄÖµ
int a = key[0], b = key[1], c = key[2], d = key[3];
for (i = 0; i £¼ times; i++) {
sum += delta;
y += ((z£¼£¼4) + a) ^ (z + sum) ^ ((z£¾£¾5) + b);
z += ((y£¼£¼4) + c) ^ (y + sum) ^ ((y£¾£¾5) + d);
}
tempInt[0]=y;
tempInt[1]=z;
return intToByte(tempInt, 0);
}
//½âÃÜ
public byte[] decrypt(byte[] encryptContent, int offset, int[] key, int times){
int[] tempInt = byteToInt(encryptContent, offset);
int y = tempInt[0], z = tempInt[1], sum = 0xC6EF3720, i;
int delta=0x9e3779b9; //ÕâÊÇËã·¨±ê×¼¸øµÄÖµ
int a = key[0], b = key[1], c = key[2], d = key[3];
for(i = 0; i £¼ times; i++) {
z -= ((y£¼£¼4) + c) ^ (y + sum) ^ ((y£¾£¾5) + d);
y -= ((z£¼£¼4) + a) ^ (z + sum) ^ ((z£¾£¾5) + b);
sum -= delta;
}
tempInt[0] = y;
tempInt[1] = z;
return intToByte(tempInt, 0);
}
//byte[]ÐÍÊý¾Ýת³Éint[]ÐÍÊý¾Ý
private int[] byteToInt(byte[] content, int offset){
int[] result = new int[content.length £¾£¾ 2]; //³ýÒÔ2µÄn´Î·½ == ÓÒÒÆnλ ¼´ content.length / 4 == content.length £¾£¾ 2
for(int i = 0, j = offset; j £¼ content.length; i++, j += 4){
result[i] = transform(content[j + 3]) | transform(content[j + 2]) £¼£¼ 8 |
transform(content[j + 1]) £¼£¼ 16 | (int)content[j] £¼£¼ 24;
}
return result;
}
//int[]ÐÍÊý¾Ýת³Ébyte[]ÐÍÊý¾Ý
private byte[] intToByte(int[] content, int offset){
byte[] result = new byte[content.length £¼£¼ 2]; //³ËÒÔ2µÄn´Î·½ == ×óÒÆnλ ¼´ conte
Ïà¹ØÎĵµ£º
À´×Ô:http://www.cnblogs.com/shiyangxt/archive/2008/07/30/1256813.html
»·¾³£ºMyEclipse
Êý¾Ý¿â£ºmysql
Ê×ÏÈн¨JavaÏîÄ¿£¬È»ºóн¨Á½¸öÀ࣬һ¸öÊý¾Ý¿âÁ¬½Ó³ØÀ࣬һ¸ö²âÊÔÀà¡£
·Ö±ðÃüÃûConnectionPool£¬ConnectionPoolTest¡£
È»ºóн¨Ò»¸öÅäÖÃÎļþ£¬ÃüÃû£ºdbpool.properties¡£
&n ......
JAVA·´Éä»úÖÆ
¸ÅÊö
¡¡¡¡ÓÐʱºòÎÒÃÇ˵ij¸öÓïÑÔ¾ßÓкÜÇ¿µÄ¶¯Ì¬ÐÔ£¬ÓÐʱºòÎÒÃÇ»áÇø·Ö¶¯Ì¬ºÍ¾²Ì¬µÄ²»Í¬¼¼ÊõÓë×÷·¨¡£ÎÒÃÇÀÊÀÊÉϿڶ¯Ì¬°ó¶¨£¨dynamic binding£©¡¢¶¯Ì¬Á´½Ó£¨dynamic linking£©¡¢¶¯Ì¬¼ÓÔØ£¨dynamic loading£©µÈ¡£È»¶ø“¶¯Ì¬”Ò»´ÊÆäʵûÓоø¶Ô¶øÆÕ±éÊÊÓõÄÑϸñ¶¨Ò壬ÓÐʱºòÉõÖÁÏñ¶ÔÏóµ¼Ïòµ±³õ±»µ¼Èë±à³ ......
Ô´´úÂ룺
public class Parent
{
protected void test() {}
public Parent()
{
this.test();
}
public static void main(String[] args)
&nb ......
public class SHA1 {
private final int[] abcde = {
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
};
// ÕªÒªÊý¾Ý´æ´¢Êý×é
&nb ......
¼ÓÃܺóÊÇÒ»¸ö32λ´óд×Öĸ×éºÏÐÎʽ£¬²¢ÇÒ±¾¼ÓÃÜ·½·¨²»¿ÉÄæ£¡
public String kljm(String dm,String kl)
{
String mw, cmm;
int k, i, tmp, a, hf, lf, bytes = 16;
int mm[], l,rand_seed;
rand_seed = 12345;
int len=kl.length();
if(len>=12) len=12;
mw =kl.substring(0,len) + dm.trim();
l = ......