一、知识点
- @Override
- public void run() {
- try {
- FileInputStream in = new FileInputStream(input);
- MessageDigest digest = MessageDigest.getInstance("SHA");
- DigestInputStream dis = new DigestInputStream(in,digest);
- while(dis.read()!=-1);
- dis.close();
- byte[] d = digest.digest();
- StringBuffer sb = new StringBuffer(input.toString());
- for(int i=0;i<d.length;i++){
- sb.append(d[i]);
- }
- System.out.println(sb.toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private File input;
- public DigestRunnable(File input){
- this.input = input;
- }
- public static void main(String[] args) {
- new Thread(new DigestRunnable(new File("1.txt"))).start();
- }