List of usage examples for com.google.gwt.core.client JsArrayInteger setLength
public final native void setLength(int newLength) ;
From source file:org.cruxframework.crux.core.client.encoder.MD5.java
License:Apache License
/** * Calculate the HMAC-MD5, of a key and some data (raw strings) *///from w w w. j av a 2 s .c om public static String rawHmacMD5(String key, String data) { JsArrayInteger bkey = rstr2binl(key); if (bkey.length() > 16) bkey = binl2md5(bkey, key.length() * 8); JsArrayInteger ipad = JsArrayInteger.createArray().cast(); JsArrayInteger opad = JsArrayInteger.createArray().cast(); ipad.setLength(16); opad.setLength(16); for (int i = 0; i < 16; i++) { ipad.set(i, bkey.get(i) ^ 0x36363636); opad.set(i, bkey.get(i) ^ 0x5C5C5C5C); } JsArrayInteger hash = binl2md5(concat(ipad, rstr2binl(data)), 512 + data.length() * 8); return binl2rstr(binl2md5(concat(opad, hash), 512 + 128)); }