main.java

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

JAVA
45
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package sha1lab;/** * * @author Fredrik */public class Main {    /**     * @param args the command line arguments     */    public static void main(String[] args) {        // Hash the test messages in the SHA-1 standard document        String message="abc";        byte[] messageByte=message.getBytes();        for(int i=0;i<messageByte.length;i++)            System.out.printf("%02x ",messageByte[i]);        System.out.println();        SHA1 hashFunction = new SHA1();        byte[] hashVal=hashFunction.hash(messageByte);        for(int i=0;i<20;i++)            System.out.printf("%02x ",hashVal[i]);        System.out.println();        message="abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";        messageByte=message.getBytes();        hashVal=hashFunction.hash(messageByte);        for(int i=0;i<20;i++)            System.out.printf("%02x ",hashVal[i]);        System.out.println();        messageByte=new byte[1000000];        for(int i=0;i<1000000;i++)            messageByte[i]="a".getBytes()[0];        hashVal=hashFunction.hash(messageByte);        for(int i=0;i<20;i++)            System.out.printf("%02x ",hashVal[i]);        System.out.println();            }}

⌨️ 快捷键说明

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