예제 #1
0
파일: MD5.java 프로젝트: foxair/winter
 /**
  * Gets the MD5 hash the data on the given InputStream.
  *
  * @param in byte array for which an MD5 hash is desired.
  * @return Array of 16 bytes, the hash of all updated bytes.
  * @throws IOException if an I/O error occurs.
  */
 public static byte[] getHash(InputStream in) throws IOException {
   MD5 md5 = new MD5();
   byte[] buffer = new byte[1024];
   int read;
   while ((read = in.read(buffer)) != -1) {
     md5.update(buffer, read);
   }
   return md5.getHash();
 }
예제 #2
0
파일: MD5.java 프로젝트: foxair/winter
 /**
  * Gets the MD5 hash of the given String.
  *
  * @param s String for which an MD5 hash is desired.
  * @param enc The name of a supported character encoding.
  * @return Array of 16 bytes, the hash of all updated bytes.
  * @throws UnsupportedEncodingException If the named encoding is not supported.
  */
 public static byte[] getHash(String s, String enc) throws UnsupportedEncodingException {
   MD5 md5 = new MD5();
   md5.update(s, enc);
   return md5.getHash();
 }
예제 #3
0
파일: MD5.java 프로젝트: foxair/winter
 /**
  * Gets the MD5 hash of the given byte array.
  *
  * @param b byte array for which an MD5 hash is desired.
  * @return Array of 16 bytes, the hash of all updated bytes.
  */
 public static byte[] getHash(byte[] b) {
   MD5 md5 = new MD5();
   md5.update(b);
   return md5.getHash();
 }
예제 #4
0
파일: MD5.java 프로젝트: foxair/winter
 /**
  * Gets the MD5 hash of the given String. The string is converted to bytes using the current
  * platform's default character encoding.
  *
  * @param s String for which an MD5 hash is desired.
  * @return Array of 16 bytes, the hash of all updated bytes.
  */
 public static byte[] getHash(String s) {
   MD5 md5 = new MD5();
   md5.update(s);
   return md5.getHash();
 }