main.java

来自「AES,DES,RSA,SHA1四个加密解密算法。」· Java 代码 · 共 43 行

JAVA
43
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package SHA1;import java.io.File;import java.io.FileInputStream;import java.io.IOException;/** * * @author Fredrik */public class Main {    /**     * @param args the command line arguments     */    public static void main(String[] args) throws IOException{        // Hash the test messages in the SHA-1 standard document    	 String filename = "D:\\My Documents\\test.JPG";         File sourceFile = new File(filename);         //String enfile = filename + ".encrypt";         //File encryptfile = new File(enfile);         int fileSize = (int) (sourceFile.length());         byte[] buff = new byte[fileSize]; 		//FileOutputStream out = null; 		FileInputStream in = new FileInputStream(sourceFile); 		in.read(buff); 		in.close();        SHA1 hashFunction = new SHA1();        for(int i=0;i<buff.length;i++)            buff[i]="a".getBytes()[0];        byte[]hashVal=hashFunction.hash(buff);        for(int i=0;i<20;i++)            System.out.printf("%02x ",hashVal[i]);        System.out.println();            }}

⌨️ 快捷键说明

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