加密解密MD5

1,MD5加密!android 自带的MessageDigest

MessageDigest mDigest = MessageDigest.getInstance("MD5");
 byte[] buf = null;
 mDigest.update(buf);
 mDigest.digest();

        /**
	 * 加密
	 */
	public String encode(InputStream inputStream){
		if(null == mDigest || null == inputStream){
			return null;
		}
		
		byte[] buf = new byte[2048];
		int readNum = 0;
		try {
			while ((readNum = inputStream.read(buf)) > 0) {
				mDigest.update(buf,0,readNum);
			}
			return toHexString(mDigest.digest());
		} catch (IOException e) {
			
			e.printStackTrace();
		}
		
		return null;
	}
 
 

 

你可能感兴趣的:(MD5,MessageDigest)