main.java

来自「提供JAVA源码」· Java 代码 · 共 53 行

JAVA
53
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package deslab;/** * * @author Fredrik */public class Main {    /**     * @param args the command line arguments     */    public static void main(String[] args) {        long plaintext,ciphertext,key;                //performs three encryptions and decryptions        //the values are taken from http://www.skepticfiles.org/faq/testdes.htm                //run the first test message        key=0x0101010101010101l;        plaintext=0x95F8A5E5DD31D900l;        DES cipher=new DES(key);        ciphertext=cipher.encrypt(plaintext);        System.out.printf("key=%016x\tplaintext=%016x\tciphertext=%016x\n",key,plaintext,ciphertext);        long plain2=cipher.decrypt(ciphertext);        System.out.printf("key=%016x\tplaintext=%016x\tciphertext=%016x\n",key,plain2,ciphertext);                //run the second test message        plaintext=0x0000000000000000l;        key=0x8001010101010101l;        DES cipher2=new DES(key);        ciphertext=cipher2.encrypt(plaintext);        System.out.printf("key=%016x\tplaintext=%016x\tciphertext=%016x\n",key,plaintext,ciphertext);        plain2=cipher2.decrypt(ciphertext);        System.out.printf("key=%016x\tplaintext=%016x\tciphertext=%016x\n",key,plain2,ciphertext);                //run the third test message        plaintext=0x01A1D6D039776742l;        key=0x7CA110454A1A6E57l;        DES cipher3=new DES(key);        ciphertext=cipher3.encrypt(plaintext);        System.out.printf("key=%016x\tplaintext=%016x\tciphertext=%016x\n",key,plaintext,ciphertext);        plain2=cipher3.decrypt(ciphertext);        System.out.printf("key=%016x\tplaintext=%016x\tciphertext=%016x\n",key,plain2,ciphertext);            }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?