Java??4???????????????
?????loading ???????[ 2017/4/27 11:26:10 ] ?????????? Java
	????????java???????У?
	????1??BASE64 ???????????????????????????
	????2??MD5(Message Digest algorithm 5?????????)
	????3??SHA(Secure Hash Algorithm??????????)
	????4??HMAC(Hash Message Authentication Code??????????????)
	????1. BASE64
	????Base64????????????????????8Bit??????????????????????RFC2045??RFC2049????????MIME??????淶??Base64???????????HTTP?????′?????????????????磬??Java Persistence??Hibernate?У???????Base64??????????????????????128-bit??UUID?????????????????????HTTP?????HTTP GET URL?е?????????????????????У???????????????????????????????URL???????????????е???????????????Base64??????в?????????????????????????????????????????
	????java??????
	package com.cn.???????;
	import sun.misc.BASE64Decoder;
	import sun.misc.BASE64Encoder;
	/*
	BASE64???????????????????????.
	BASE64Encoder??BASE64Decoder?????JDK??????????????JDK???????????????????API??鯔????
	JRE ?? sun ?? com.sun ???????????δ?????????????????? java?? javax ????????????е???????????????й??
	?????????????????
	BASE64 ???????????????????????????
	?????BASE64Encoder??BASE64Decoder??????????????????????????????ɡ?
	???BASE?????????????λ????8??????????????λ????=???????
	BASE64
	????RFC2045????壬Base64?????????Base64??????????????????????????е?8λ?????????????????????????????
	??The Base64 Content-Transfer-Encoding is designed to represent arbitrary sequences of octets in a form that need not be humanly readable.??
	???????????http????????http???????????????????????????????????BASE64??????
	*/
	public class BASE64 {
	/**
	* BASE64????
	*
	* @param key
	* @return
	* @throws Exception
	*/
	public static byte[] decryptBASE64(String key) throws Exception {
	return (new BASE64Decoder()).decodeBuffer(key);
	}
	/**
	* BASE64????
	*
	* @param key
	* @return
	* @throws Exception
	*/
	public static String encryptBASE64(byte[] key) throws Exception {
	return (new BASE64Encoder()).encodeBuffer(key);
	}
	public static void main(String[] args) {
	String str="12345678";
	try {
	String result1= BASE64.encryptBASE64(str.getBytes());
	System.out.println("result1=====????????=========="+result1);
	byte result2[]= BASE64.decryptBASE64(result1);
	String str2=new String(result2);
	System.out.println("str2========????????========"+str2);
	} catch (Exception e) {
	e.printStackTrace();
	}
	}
	}
	????2. MD5
	????MD5??Message-Digest Algorithm 5?????-????5????????????????????????????????????????????????????????????????????????????????????MD5????????????紡?????????????????????????????????????MD5???????MD2??MD3??MD4?????????????????????????????У?顣У?飿??????????????MD5?????????MD5???????????ISOУ?飬????MD5У?顣????????????ISO????MD5?????MD5????????????linux-ISO?????????????????????????MD5??????????????????????μ??
	????java???
	package com.cn.???????;
	import java.math.BigInteger;
	import java.security.MessageDigest;
	/*
	MD5(Message Digest algorithm 5?????????)
	??????????????????MD5??????????MD5????????????齻??BASE64??????????????????????
	Digest:???
	*/
	public class MD5 {
	public static final String KEY_MD5 = "MD5";
	public static String getResult(String inputStr)
	{
	System.out.println("=======???????????:"+inputStr);
	BigInteger bigInteger=null;
	try {
	MessageDigest md = MessageDigest.getInstance(KEY_MD5);
	byte[] inputData = inputStr.getBytes();
	md.update(inputData);
	bigInteger = new BigInteger(md.digest());
	} catch (Exception e) {e.printStackTrace();}
	System.out.println("MD5?????:" + bigInteger.toString(16));
	return bigInteger.toString(16);
	}
	public static void main(String args[])
	{
	try {
	String inputStr = "??????8888888888888888888";
	getResult(inputStr);
	} catch (Exception e) {
	e.printStackTrace();
	}
	}
	}
	????MD5?????????????
	????1?????????????????????????MD5?????????????
	????2????????????????????MD5????????
	????3?????????????????????κθ????????????1?????????????MD5????к??????
	????4??????????????????????MD5??????????????????MD5??????????α?????????????????
	????5??????????????????????????????????????????MD5?????????????
	????MD5????????????????????????????????????????????”???”???????????????????????????????任?????????????????????????????MD5???????б???????????sha-1??RIPEMD???Haval???
	????3.SHA
	??????????????Secure Hash Algorithm???????????????????????Digital Signature Standard DSS?????漲??????????????Digital Signature Algorithm DSA???????????С??2^64λ???????SHA1????????160λ????????????????????????????????????????????????????????á??????????????????????????????????????????????????Σ??????С???????????????????????????????????????????????????????????????λ?????????????м????????????????????????????????????к????????????????????“???”????“??”??????????????????????????????????????????
	????java????
	package com.cn.???????;
	import java.math.BigInteger;
	import java.security.MessageDigest;
	/*
	SHA(Secure Hash Algorithm??????????????????????????????????????????
	??????????????????????????????????SHA??MD5??????????????????
	????SHA??????????????????????MD5??????*/
	public class SHA {
	public static final String KEY_SHA = "SHA";
	public static String getResult(String inputStr)
	{
	BigInteger sha =null;
	System.out.println("=======???????????:"+inputStr);
	byte[] inputData = inputStr.getBytes();
	try {
	MessageDigest messageDigest = MessageDigest.getInstance(KEY_SHA);
	messageDigest.update(inputData);
	sha = new BigInteger(messageDigest.digest());
	System.out.println("SHA?????:" + sha.toString(32));
	} catch (Exception e) {e.printStackTrace();}
	return sha.toString(32);
	}
	public static void main(String args[])
	{
	try {
	String inputStr = "??????";
	getResult(inputStr);
	} catch (Exception e) {
	e.printStackTrace();
	}
	}
	}
	????SHA-1??MD5????
	??????????????MD4??????SHA-1??MD5????????????????????????????????????????????????????????
	????l ????й???????????????????????????SHA-1????MD5????32 λ???????м??????????κ??????????????????????????????MD5??2^128?????????????????SHA-1????2^160???????????????????SHA-1????й????и????????
	????l ????????????????????MD5????????????????????????SHA-1??ò????????????????
	????l ?????????????????SHA-1??????????MD5????
	
??????
					
					???·???
App??С????H5?????????????????Щ??
2024/9/11 15:34:34?????????????????????????
2024/9/10 11:13:49P-One ???????????????????????????????????????
2024/9/10 10:14:12???????????????????????????
2024/9/9 18:04:26??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44
					
			
								
								
								
								
								
								
								
								
								
								
				
sales@spasvo.com