• 大小: 7KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: Java
  • 标签: AES  java  

资源简介

密码学作业之一,辛辛苦苦实现的哎。网上的搜到的AES还是DES的S盒有个地方是不一样的。同学找了半天才找出来。有点不太记得了。几个月之前写的,供大家参考学习。环境就是eclipse

资源截图

代码片段和文件信息

public class AESclass {
static int Nr=10;
static int key[]={0x2B0x7E0x150x160x280xAE0xD20xA60xAB0xF70x150x880x090xCF0x4F0x3C};
static int text[]={0x320x430xF60xA80x880x5A0x300x8D0x310x310x980xA20xE00x370x070x34};
static int sbox[]={
0x630x7C0x770x7B0xF20x6B0x6F0xC50x300x010x670x2B0xFE0xD70xAB0x76
0xCA0x820xC90x7D0xFA0x590x470xF00xAD0xD40xA20xAF0x9C0xA40x720xC0
0xB70xFD0x930x260x360x3F0xF70xCC0x340xA50xE50xF10x710xD80x310x15
0x040xC70x230xC30x180x960x050x9A0x070x120x800xE20xEB0x270xB20x75  
0x090x830x2C0x1A0x1B0x6E0x5A0xA00x520x3B0xD60xB30x290xE30x2F0x84  
0x530xD10x000xED0x200xFC0xB10x5B0x6A0xCB0xBE0x390x4A0x4C0x580xCF  
0xD00xEF0xAA0xFB0x430x4D0x330x850x450xF90x020x7F0x500x3C0x9F0xA8  
0x510xA30x400x8F0x920x9D0x380xF50xBC0xB60xDA0x210x100xFF0xF30xD2  
0xCD0x0C0x130xEC0x5F0x970x440x170xC40xA70x7E0x3D0x640x5D0x190x73
0x600x810x4F0xDC0x220x2A0x900x880x460xEE0xB80x140xDE0x5E0x0B0xDB  
0xE00x320x3A0x0A0x490x060x240x5C0xC20xD30xAC0x620x910x950xE40x79  
0xE70xC80x370x6D0x8D0xD50x4E0xA90x6C0x560xF40xEA0x650x7A0xAE0x08  
0xBA0x780x250x2E0x1C0xA60xB40xC60xE80xDD0x740x1F0x4B0xBD0x8B0x8A  
0x700x3E0xB50x660x480x030xF60x0E0x610x350x570xB90x860xC10x1D0x9E  
0xE10xF80x980x110x690xD90x8E0x940x9B0x1E0x870xE90xCE0x550x280xDF  
0x8C0xA10x890x0D0xBF0xE60x420x680x410x990x2D0x0F0xB00x540xBB0x16 
};
static int RCon[];
static int word[][];
public static void main(String[] args) {
keyExpansion();
int ir=0;
text=addRoundKey(text0);
// System.out.println(“No.0 add roundKey:“);
for(i=0;i<16;i++){
// System.out.print(Integer.toHexString(text[i])+‘‘);
if(i%4==3){
// System.out.println();
}
}
// System.out.println();
r++;
for(;r<=Nr;r++){
for(i=0;i<16;i++){
text[i]=subByte(text[i]);
}
// System.out.println(“subByte:“);
for(i=0;i<16;i++){
// System.out.print(Integer.toHexString(text[i])+‘‘);
if(i%4==3){
// System.out.println();
}
}
text=shiftRows(text);
// System.out.println(“No.“+r+“ shiftRows:“);
for(i=0;i<16;i++){
// System.out.print(Integer.toHexString(text[i])+‘‘);
if(i%4==3){
// System.out.println();
}
}
if(r!=10){
text=mixColumn(text);
// System.out.println(“No.“+r+“ mixColumn:“);
for(i=0;i<16;i++){
// System.out.print(Integer.toHexString(text[i])+‘‘);
if(i%4==3){
// System.out.println();
}
}
}
text=addRoundKey(text r);
// System.out.println(“No.“+r+“ add roundKey:“);
for(i=0;i<16;i++){
// System.out.print(Integer.toHexString(text[i])+‘‘);
if(i%4==3){
// System.out.println();
}
}
// System.out.printl

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-03-12 15:43  AES\
     文件         301  2017-03-12 15:43  AES\.classpath
     文件         379  2017-03-12 15:43  AES\.project
     目录           0  2017-03-12 15:43  AES\.settings\
     文件         598  2017-03-12 15:43  AES\.settings\org.eclipse.jdt.core.prefs
     目录           0  2017-03-27 10:49  AES\bin\
     文件        5858  2017-03-27 10:49  AES\bin\AESclass.class
     目录           0  2017-03-14 15:33  AES\src\
     文件        5169  2017-03-19 11:21  AES\src\AESclass.java

评论

共有 条评论