资源简介
华科密码学2014年课设,包括SPN的课本算法实现,增加轮数,增加分组长度的加强版本可通过随机性检测的SPN实现,SPN的差分以及线性攻击实现,暴力破解算法实现;DES算法实现,DES加解密文件算法实现,RSA算法实现。经过中国剩余定理以及蒙哥马利算法优化的RSA算法实现。
代码片段和文件信息
package com.cyc.www.cry;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* @since 2014/9/4
* @author Hust
* 密钥为64位,明文,密文均处理成64位分组,输入时数字用16进制表示
* 加密文件时不考虑文件的编码方式,只需要处理底层的字节流就可以了
*/
public class DesTest {
public DesTest() {
}
public static void main(String[] args) throws IOException {
//long plain = 0x0123456789ABCDEFL key = 0xFEDCBA9876543210L;
//long plain = 0Lkey = 0L;
//long plain = 0xFFFFFFFFFFFFFFFFLkey = 0xFFFFFFFFFFFFFFFFL;
long plain =0x51454B582DDF440AL key = 0x3849674C2602319EL;
// long plain = 0x6c6561726e696e67Lkey = 0x636f6d7075746572L;
//long plain = 0x434f4d5055544552L key = 0x5345435552495459L;
DesTest desTest = new DesTest();
desTest.getKey56(key);
desTest.showEnAndDeDemo(key plain);
}
public void showEnAndDeDemo(long keylong plain) throws IOException {
System.out.printf(“明文是:%x\n“plain);
long plainlong = Encry(plain key);
System.out.printf(“加密最终的结果是:%x\n“ plainlong);
long result = deCry(plainlong);
System.out.printf(“解密的结果:%x\n“result);
EncryFile(“D:\\测试文件.txt“ “D:\\1.txt“);
DecryFile(“D:\\1.txt“ “D:\\2.txt“);
}
public long Encry(long plainlong key) {
long[] [] plaingroup = new long[17][2];
plaingroup[0] = IPSub(plain IPTable);
for (int i = 0; i < 16; i++) {
plaingroup[i+1] =encryOne(plaingroup[i] keyArrage(i));
}
long plainlong = (plaingroup[16][1]<<32) + plaingroup[16][0];
long[] plainlongtemp = new long[2];
plainlongtemp= IPSub(plainlong UnIPTable);
plainlong = (plainlongtemp[0] << 32) + plainlongtemp[1];
return plainlong;
}
public long deCry(long cihper) {
long [][] decry = new long[17][2];
decry[0] = IPSub(cihper IPTable);
for (int i = 0; i < 16; i++) {
decry[i+1] = encryOne(decry[i]keyArrage(15 - i));
}
long crylongF = (decry[16][1]<<32) + decry[16][0];
long[] crylongtemp = new long[2];
crylongtemp= IPSub(crylongF UnIPTable);
crylongF = (crylongtemp[0]<<32) + crylongtemp[1];
return crylongF;
}
/*
* 加密文件
*/
public void EncryFile(String plainFileString cipherFile) throws IOException {
long last = 0x0808080808080808L;
byte[] lastbit = new byte[8];
long plainTemp = 0x0L;
long cipherTemp = 0x0L;
long key = 0x3849674C2602319EL;
try {
FileInputStream fin = new FileInputStream(plainFile);
FileOutputStream fout = new FileOutputStream(cipherFiletrue);
DataInputStream din = new DataInputStream(fin);
DataOutputStream dOut = new DataOutputStream(fout);
RandomAccessFile in = new RandomAccessFile(plainFile “r“);
long length = in.length();
long groups = length/8;
long yuuu = length%8;
for (int i = 0; i < groups; i++) {
plainTemp = din.readLong();
cipherTemp = Encry(plainTemp key)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 301 2014-07-13 09:43 CryTest\.classpath
文件 383 2014-07-21 10:48 CryTest\.project
目录 0 2014-09-06 21:51 CryTest\.settings\
文件 598 2014-07-13 09:43 CryTest\.settings\org.eclipse.jdt.core.prefs
目录 0 2014-09-07 10:48 CryTest\bin\
目录 0 2014-09-07 10:48 CryTest\bin\com\
目录 0 2014-09-07 10:48 CryTest\bin\com\cyc\
目录 0 2014-09-07 10:48 CryTest\bin\com\cyc\www\
目录 0 2014-09-12 23:39 CryTest\bin\com\cyc\www\cry\
文件 12083 2014-09-12 19:40 CryTest\bin\com\cyc\www\cry\DesTest.class
文件 2699 2014-09-12 20:54 CryTest\bin\com\cyc\www\cry\MgmlDemo.class
文件 3668 2014-09-12 09:46 CryTest\bin\com\cyc\www\cry\RSA.class
文件 6473 2014-09-12 23:36 CryTest\bin\com\cyc\www\cry\SPN.class
文件 6034 2014-09-11 15:33 CryTest\bin\com\cyc\www\cry\SPN_ATTACK_DIFF.class
文件 6278 2014-09-11 15:24 CryTest\bin\com\cyc\www\cry\SPN_ATTACK_LINEAR.class
文件 5630 2014-09-07 10:48 CryTest\bin\com\cyc\www\cry\SPNF.class
目录 0 2014-09-02 19:36 CryTest\src\
目录 0 2014-09-02 19:36 CryTest\src\com\
目录 0 2014-09-02 19:36 CryTest\src\com\cyc\
目录 0 2014-09-02 19:36 CryTest\src\com\cyc\www\
目录 0 2014-09-12 23:39 CryTest\src\com\cyc\www\cry\
文件 13433 2014-09-12 19:40 CryTest\src\com\cyc\www\cry\DesTest.java
文件 1882 2014-09-12 20:54 CryTest\src\com\cyc\www\cry\MgmlDemo.java
文件 3167 2014-09-12 09:46 CryTest\src\com\cyc\www\cry\RSA.java
文件 5190 2014-09-12 23:36 CryTest\src\com\cyc\www\cry\SPN.java
文件 6265 2014-09-11 15:33 CryTest\src\com\cyc\www\cry\SPN_ATTACK_DIFF.java
文件 6898 2014-09-11 15:24 CryTest\src\com\cyc\www\cry\SPN_ATTACK_LINEAR.java
文件 5538 2014-09-07 10:45 CryTest\src\com\cyc\www\cry\SPNF.java
文件 2407 2014-09-02 10:45 CryTest\测试数据.txt
- 上一篇:黑客工具包大全.doc
- 下一篇:DNS隐秘隧道pcap包
相关资源
- Altium Designer 3D模型库
- IBM Rational Harmony Deskbook _基于模型的系
- 情感化设计 Emotional Design 中文版
- 完整中文版Introduction to Lens Design Wit
- stm32各种原理图和PCB集锦Altium Designe
- Altium Designer集成库 AD库
- 线性稳压电源 pcb Altium Designer Winter
- DES 纯c实现(des.c和des.h) 含pkcs1填充
- Autodesk Inventor2008注冊機AUTODESK.INVENTO
- 离散扩张状态观测器,实现扰动估计
- Design and Implementation of the lwIP TCP_IP S
- XenDesktop XenApp 7.15 LTSR CU4.txt
- Citrix桌面虚拟化项目手册-XenDesktop服务
- my_antd_design_pro.pptx
- 论文研究 - 香根草Vetiveria zizanioides在
- 蓝色宽屏B2B行业网站源码+最新完整版
- Probabilistic representation for solution of s
-
Transition me
tal-Free One-Pot Protocol towa - 将超出Horndeski的高阶标量-张量理论退
- Horndeski以外的标量-张量理论的哈密顿
- hands-on_design-patterns-delphi_pdf-code.rar
- neo4j-desktop-offline-1.2.4-setup.exe
- 论文研究 - 在30°漂移下KVLCC2的前躯
- Catalytic Adsorptive Desulfurization Using TiO
- 123D Design 1.8 中文包
- 《Struts 2.x权威指南(第3版)》.(李
- Design_compiler经典教程
- .NET Reflector 5.0 ReleaseCodeSearch.zip
- (Salen)Ti(IV)-Catalyzed Asymmetric Rin
- VDI_Waveguide_Designations
评论
共有 条评论