????????java???????У?
????BASE64???????????????????????????
????MD5(Message Digest algorithm 5?????????)
????SHA(Secure Hash Algorithm??????????)
????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???