Simple expample of MessageDigest

1167 단어 SecurityJava
더 읽 기
When use the encrypted arithmetic to encrypt some files.we can use the method create by MessageDigest:
package com.CAHelper;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MyTest {

	public static void main(String args[]){
		String info = "This is my test info: Hello World";
		try {
			MessageDigest digester = MessageDigest.getInstance("SHA-1");
			System.out.println("Method is :"+digester.getAlgorithm());
			digester.update(info.getBytes());
			byte[] digeByte = digester.digest(); 
			System.out.println("Info is :"+byte2hex(digeByte));
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static String byte2hex(byte[] b){
		String hs = "";
		String stemp = "";
		System.out.println(b.length);
		for(int i=0;i 
 

 

좋은 웹페이지 즐겨찾기