@@ -0,0 +1,1543 @@
+package net.oschina.crypto;%0A%0Aimport java.security.Key;%0Aimport java.security.NoSuchAlgorithmException;%0A%0Aimport javax.crypto.Cipher;%0Aimport javax.crypto.KeyGenerator;%0Aimport javax.crypto.SecretKey;%0Aimport javax.crypto.spec.SecretKeySpec;%0A%0Apublic abstract class   RC2Coder %7B%0A%09/**%0A%09 * %0A%09 * @return%0A%09 * @throws NoSuchAlgorithmException%0A%09 */%0A%09public static byte%5B%5D initKey() throws NoSuchAlgorithmException %7B%0A%09%09KeyGenerator kg = KeyGenerator.getInstance(KEY_ALGORITHM);%0A%09%09//kg.init(256);%0A%09%09SecretKey secretKey = kg.generateKey();%0A%09%09return secretKey.getEncoded();%0A%0A%09%7D%0A%0A%09/**%0A%09 * %0A%09 * %0A%09 * @param data%0A%09 * @param key%0A%09 * @return%0A%09 * @throws Exception%0A%09 */%0A%09public static byte%5B%5D encypt(byte%5B%5D data, byte%5B%5D key) throws Exception %7B%0A%09%09Key key2 = toKey(key);%0A%09%09Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);%0A%09%09cipher.init(Cipher.ENCRYPT_MODE, key2);%0A%09%09return cipher.doFinal(data);%0A%0A%09%7D%0A%0A%09/**%0A%09 * %0A%09 * @param key%0A%09 * @return%0A%09 * @throws Exception%0A%09 */%0A%09private static Key toKey(byte%5B%5D key) throws Exception %7B%0A%09%09SecretKey secretKey = new SecretKeySpec(key, KEY_ALGORITHM);%0A%09%09return secretKey;%0A%09%7D%0A%0A%09/**%0A%09 * %0A%09 * %0A%09 * @param data%0A%09 * @param key%0A%09 * @return%0A%09 * @throws Exception%0A%09 */%0A%09public static byte%5B%5D decypt(byte%5B%5D data, byte%5B%5D key) throws Exception %7B%0A%09%09Key key2 = toKey(key);%0A%09%09Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);%0A%09%09cipher.init(Cipher.DECRYPT_MODE, key2);%0A%09%09return cipher.doFinal(data);%0A%09%7D%0A%0A%09/**%0A%09 * %E3%B7%A8%0A%09 */%0A%09public static final String KEY_ALGORITHM = %22RC2%22;%0A%0A%09public static final String CIPHER_ALGORITHM = %22RC2/ECB/PKCS5Padding%22;%0A%7D%0A

添加rc2算法