?? initpsw.java
字號:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package s_des;/** * * @author CJPHENRY */public class InitPSW { /** * @param args the command line arguments */ public int[] PSW; public int[] P10; public int[] LS1; public int[] K1; public int[] LS2; public int[] K2; InitPSW(){ PSW = new int[10]; P10 = new int[10]; LS1 = new int[10]; K1 = new int[8]; LS2 = new int[10]; K2 = new int[8]; } public void calculate(int[] inf){ setPSW(inf); setP10(); LS1(); createK1(); LS2(); createK2(); disPlay(PSW); disPlay(P10); disPlay(LS1); disPlay(K1); disPlay(LS2); disPlay(K2); } private void setPSW(int[] inf){ for(int i = 0; i < inf.length ;i++){ PSW[i] = inf[i]; } } private void setP10(){ P10[0] = PSW[2]; P10[1] = PSW[4]; P10[2] = PSW[1]; P10[3] = PSW[6]; P10[4] = PSW[3]; P10[5] = PSW[9]; P10[6] = PSW[0]; P10[7] = PSW[8]; P10[8] = PSW[7]; P10[9] = PSW[5]; } private void createK1(){ K1[0] = LS1[5]; K1[1] = LS1[2]; K1[2] = LS1[6]; K1[3] = LS1[3]; K1[4] = LS1[7]; K1[5] = LS1[4]; K1[6] = LS1[9]; K1[7] = LS1[8]; } private void createK2(){ K2[0] = LS2[5]; K2[1] = LS2[2]; K2[2] = LS2[6]; K2[3] = LS2[3]; K2[4] = LS2[7]; K2[5] = LS2[4]; K2[6] = LS2[9]; K2[7] = LS2[8]; } private void LS1(){ //LS1,左半密鑰循環左移一位 for(int i = 0; i < 4; i++)LS1[i] = P10[i+1]; LS1[4] = P10[0]; //LS1,右半密鑰循環左移一位 for(int i = 5; i < 9; i++)LS1[i] = P10[i+1]; LS1[9] = P10[5]; } private void LS2(){ //LS2,左半密鑰循環左移兩位 for(int i = 0; i < 3; i++)LS2[i] = LS1[i+2]; LS2[3] = LS1[0]; LS2[4] = LS1[1]; //LS2,右半密鑰循環左移兩位 for(int i = 5; i < 8; i++)LS2[i] = LS1[i+2]; LS2[8] = LS1[5]; LS2[9] = LS1[6]; } private void disPlay(int[] inf){ System.out.println(inf.length); for(int i = 0;i < inf.length;i++){ System.out.print(" " + inf[i]); } System.out.println(); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -