Code example for MessageDigest

Methods: digestupdate

0
	public static byte[] hashBytes( 
		MessageDigest d,
		byte[] b,
		int offset,
		int length) {
		d.update(b, offset, length);
		return d.digest();
	} 
 
	/** 
	 * Hashes a string in a consistent manner 
	 */ 
	public static byte[] hashString(MessageDigest d, String s) {
		try { 
			byte[] sbytes = s.getBytes("UTF-8");
			d.update(sbytes, 0, sbytes.length);
			return d.digest();
		} catch (Exception e) {
			e.printStackTrace();
		} 
Experience pair programming with AI  Get Codota for Java