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)
相关文档:
JAVA的容器---List,Map,Set
Collection
├List
│├LinkedList
│├ArrayList
│└Vector
│ └Stack
└Set
Map
├Hashtable
├HashMap
└WeakHashMap
Collection接口
Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements)。一些 Collection允许相 ......
package com.project.ajaxs;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Calendar;
import java.uti ......
转自:http://lavasoft.blog.51cto.com/62575/27069
Java多线程编程总结
一、认识多任务、多进程、单线程、多线程
要认识多线程就要从操作系统的原理说起。
以前古老的DOS操作系统(V 6.22)是单任务的,还没有线程的概念,系统在每次只能做一件事情。比如你在copy东西的时候不能rename文件名。为了提高 ......
Java Applet 是用Java 语言编写的一些小应用程序,这些程序是直接嵌入到页面中,由支持Java的浏览器(IE 或 Nescape)解释执行能够产生特殊效果的程序。它可以大大提高Web页面的交互能力和动态执行能力。包含Applet的网页被称为Java-powered页,可以称其为Java支持的网页。
当用户访问这样的网页时,Ap ......