资源简介
里面包括十几个系统,实现了rsa的加解密和数字签名,文件和消息都可以加解密,有些系统实现了socket传输,模拟客户端和服务端的模式,可以实现聊天的信息加解密,还有一些rsa系统的论文
代码片段和文件信息
package com.sohu.sce.apps.utils;
/**
* rsa256算法
* AES算法
* @author Chenhuan
*
*/
public class RSA {
private static final int CHRSZ = 8;
// private static int safe_add(int x int y) {
// int lsw = (x&0xFFFF) + (y&0xFFFF);
// int msw = (x >> 16) + (y >> 16) + (lsw >> 16);
// return (msw << 16)|(lsw & 0xFFFF);
// }
private static int safe_add (int x int y) {
int lsw = (x & 0xFFFF) + (y & 0xFFFF);
int msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
private static int S(int X int n) {
return (X >>> n) | (X << (32 - n));
}
private static int R(int X int n) {
return (X >>> n);
}
private static int Ch(int x int y int z) {
return ((x & y)^((~x)&z));
}
private static int Maj(int x int y int z) {
return ((x & y) ^ (x & z) ^ (y & z));
}
private static int Sigma0256(int x) {
return (S(x 2) ^ S(x 13) ^ S(x 22));
}
private static int Sigma1256(int x) {
return (S(x 6) ^ S(x 11) ^ S(x 25));
}
private static int Gamma0256(int x) {
return (S(x 7) ^ S(x 18) ^ R(x 3));
}
private static int Gamma1256(int x) {
return (S(x 17) ^ S(x 19) ^ R(x 10));
}
private static int[] str2binb (String str) {
int[] bin = new int[str.length() * CHRSZ];
int mask = (1 << CHRSZ) - 1;
for(int i = 0; i < str.length() * CHRSZ; i += CHRSZ)
bin[i>>5] |= (str.charAt(i / CHRSZ) & mask) << (24 - i%32);
return bin;
}
/**
* 二进制到十六进制
* @param binarray
* @return
*/
private static String binb2hex (int[] binarray) {
int hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
String hex_tab = hexcase==1 ? “0123456789ABCDEF“ : “0123456789abcdef“;
String str = ““;
for (int i = 0; i < binarray.length * 4; i++) {
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
private static int[] core_sha256 (int[] m int l) {
int[] K = new int[]{0x428A2F980x713744910xB5C0FBCF0xE9B5DBA50x3956C25B0x59F111F10x923F82A40xAB1C5ED50xD807AA980x12835B010x243185BE0x550C7DC30x72BE5D740x80DEB1FE0x9BDC06A70xC19BF1740xE49B69C10xEFBE47860xFC19DC60x240CA1CC0x2DE92C6F0x4A7484AA0x5CB0A9DC0x76F988DA0x983E51520xA831C66D0xB00327C80xBF597FC70xC6E00BF30xD5A791470x6CA63510x142929670x27B70A850x2E1B21380x4D2C6DFC0x53380D130x650A73540x766A0ABB0x81C2C92E0x92722C850xA2BFE8A10xA81A664B0xC24B8B700xC76C51A30xD192E8190xD69906240xF40E35850x106AA0700x19A4C1160x1E376C080x2748774C0x34B0BCB50x391C0CB30x4ED8AA4A0x5B9CCA4F0x682E6FF30x748F82EE0x78A5636F0x84C878140x8CC702080x90BEFFFA0xA4506CEB0xBEF9A3F70xC67178F2};
int[] HASH = new int[]{0x6A09E667 0xBB67AE85 0x3C6EF372 0xA54FF53A 0x510E527F 0x9B05688C 0x1F83D9AB 0x5BE0CD19};
int[] W = new int[64];
int a b c d e f g h;
int T1 T2;
/* append padding */
m[l >>
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 118272 2015-12-19 21:13 DigitalSignature\Debug\DigitalSignature.exe
----------- --------- ---------- ----- ----
118272 1
评论
共有 条评论