RabbitÁ÷ÃÜÂëµÄJavaʵÏÖ
1. RabbitÁ÷ÃÜÂ루Rabbit Stream Cipher£©¼ò½é
RabbitÁ÷ÃÜÂëÊÇÓÉCryptico¹«Ë¾£¨http://www.cryptico.com£©Éè¼ÆµÄ£¬ÃÜÔ¿³¤¶È128룬
×î´ó¼ÓÃÜÏûÏ¢³¤¶ÈΪ264 Bytes£¬¼´16 TB£¬ÈôÏûÏ¢³¬¹ý¸Ã³¤¶È£¬ÔòÐèÒª¸ü»»ÃÜÔ¿¶ÔʣϵÄÏûÏ¢½øÐд¦Àí¡£ËüÊÇÄ¿Ç°°²È«ÐԽϸߣ¬¼Ó/½âÃÜËٶȱȽϸßЧµÄÁ÷ÃÜÂëÖ®Ò»£¬ÔÚ¸÷ÖÖ´¦ÀíÆ÷ƽ̨É϶¼Óв»·²µÄ±íÏÖ¡£
Ïêϸ×ÊÁÏ£º
1.http://www.cryptico.com/Files/filer/rabbit_fse.pdf
2.http://www.ietf.org/rfc/rfc4503.txt
±¾ÎÄʵÏÖÁ˸ÃËã·¨µÄjavaÓïÑÔʵÏÖ£¬½ö¹©²Î¿¼¡£
2. ʵÏÖÔ´Âë
/**
* The Java Implementation of Rabbit Stream Cipher
* @author cnbragon
* @email cnbragon_dot_163_dot_com
* @date 2009/09/25
* @note Not implemented IV scheme
* @Reference:
* 1.http://www.cryptico.com/Files/filer/rabbit_fse.pdf
* 2.http://www.ietf.org/rfc/rfc4503.txt
*/
class Rabbit
{
private int[] x = new int[8];
private int[] c = new int[8];
private int carry;
public void Rabbit()
{
for(int i = 0; i < 8; i++)
{
x[i] = c[i] = 0;
}
carry = 0;
}
private int g_func(int x)
{
int a = x & 0xffff;
int b = x >>> 16;
int h =( ( ( ( a * a ) >>> 17 ) + ( a * b ) ) >>> 15 ) + b * b;
int l = x * x;
return h ^ l;
}
/**
* @declaration ±È½ÏÁ½¸öÓзûºÅÕûÊýµÄÊ®Áù½øÖƵĴóС£¬¼´×÷ΪÎÞ·ûºÅÕûÊý½øÐбȽÏ
* @param x
* @param y
* @return Èô(unsigned x) < (unsigned y)£¬Ôò·µ»Ø1£¬·ñÔò·µ»Ø0
*/
private int compare(int x, int y)
{
long a = x;
long b = y;
a &= 0x00000000ffffffffl;
b &= 0x00000000ffffffffl;
return (a < b) ? 1 : 0;
}
private int rotL(int x, int y)
Ïà¹ØÎĵµ£º
package thread.lock;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @file_name ReadAndWriteLockDemo.java
* @description ¶ÁÐ ......
JAVAµÄÈÝÆ÷---List,Map,Set
Collection
©ÀList
©¦©ÀLinkedList
©¦©ÀArrayList
©¦©¸Vector
©¦¡¡©¸Stack
©¸Set
Map
©ÀHashtable
©ÀHashMap
©¸WeakHashMap
Collection½Ó¿Ú
¡¡¡¡CollectionÊÇ×î»ù±¾µÄ¼¯ºÏ½Ó¿Ú£¬Ò»¸öCollection´ú±íÒ»×éObject£¬¼´CollectionµÄÔªËØ£¨Elements£©¡£Ò»Ð© CollectionÔÊÐíÏà ......
1. ¹ØÓÚConnection Pool
JDBC±¾Éí²»ÌṩÁ¬½Ó³Ø¼¼Êõ£¬ÐèÒªµÚÈý·½¿âµÄÖ§³Ö¡£
ÔÚÐèҪƵ·±»ñµÃÁ¬½ÓµÄApplicationÖÐ×îºÃÓÃConnection Pool£¬ÈçWeb ApplicationÖÐ
¶ÔÓÚÒ»°ãµÄJava ApplicationÔò¿ÉÒÔÖ±½ÓÓÃJDBCÁ¬½ÓÊý¾Ý¿â¡£
2. Java ApplicationÖÐÁ¬½ÓDB2
°²×°DB2 Personal Edition V9Ö®ºó£¬ÔÚÆäÖ ......
×Ô¶¨ÒåµÄKeyÀàÐèÒªÖØÔØequals, hashCodeº¯Êý¡£¡£
package com.albert.test;
import java.util.Vector;
import java.util.HashMap;
/**
* @author tough_guy
*
*/
//¶ÔÓÚ×Ô¶¨ÒåµÄkey£¬ ÐèÒªÖØÔØhashCodeº¯ÊýºÍequalsº¯Êý
class IPSegment
{
long ip_s;
long ip_e;
int p;
IPSegment Reset(long f ......