Code example for MessageDigest

Methods: digestupdate

0
	 * 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();
		} 
		return null; 
	} 
 
	public static byte[] xor(byte[] b1, byte[] b2) {
		int maxl = Math.max(b1.length, b2.length);
		byte[] rv = new byte[maxl];
 
		int minl = Math.min(b1.length, b2.length);
		for (int i = 0; i < minl; i++)
			rv[i] = (byte) (b1[i] ^ b2[i]);
Stop searching for code, let great code find you!  Add Codota to your java IDE