2012年12月6日 星期四

MessageDigest

java.security
Class MessageDigest

java.lang.Object
  extended byjava.security.MessageDigestSpi
      extended byjava.security.MessageDigest 
 
 This MessageDigest class provides applications the functionality of a
 message digest algorithm, such as MD5 or SHA. 
 
 MessageDigest md = MessageDigest.getInstance("MD5");
 byte[] hashConde;
 md.update(number.getBytes());
 hashConde = md.digest(); 
 


 byte[] digest()
          Completes the hash computation by performing final operations such as padding. 取的值須儲存為byte[] 型態
 
 
參考 http://caterpillar.onlyfun.net/Gossip/Encoding/String.html
 byte[] getBytes()
          Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array. 使用平台預設的編碼, 儲存為byte陣列
 




參考 http://www.dotblogs.com.tw/chhuang/archive/2011/01/19/20883.aspx
 void update(byte[] input)
          Updates the digest using the specified array of bytes. 計算byte[] 的演算法的值(MessageDigest)

沒有留言:

張貼留言