Closed GoogleCodeExporter closed 9 years ago
Exception stack trace logged in GWT Hostedmode follows:
java.lang.ArrayIndexOutOfBoundsException: 9
at com.googlecode.gwt.crypto.bouncycastle.digests.SHA1Digest.unpackWord
(SHA1Digest.java:77)
at com.googlecode.gwt.crypto.bouncycastle.digests.SHA1Digest.doFinal
(SHA1Digest.java:102)
Original comment by lloyd.bo...@gmail.com
on 16 Sep 2009 at 1:01
Sample code that has the above exception follows:
SHA1Digest digest = new SHA1Digest();
byte[] inputBytes = Str.toBytes(passwordString.toCharArray());
digest.update(inputBytes, 0, inputBytes.length);
digest.doFinal(inputBytes, 0);
Original comment by lloyd.bo...@gmail.com
on 16 Sep 2009 at 1:06
Original comment by moor...@gmail.com
on 4 Oct 2009 at 4:08
Here's a PDF of the code that the SHA1Digest class is based upon:
http://www.cacr.math.uwaterloo.ca/hac/about/chap9.pdf
Original comment by moor...@gmail.com
on 4 Oct 2009 at 4:14
Lloyd,
After looking at this, I believe you need to zero pad the inputBytes as so:
String passwordString = "abcdefghi";
SHA1Digest digest = new SHA1Digest();
byte[] inputBytes = new byte[digest.getDigestSize()];
byte[] pwBytes = passwordString.getBytes();
for (int i = 0; i < pwBytes.length; i++) {
inputBytes[i] = pwBytes[i];
}
digest.update(inputBytes, 0, inputBytes.length);
int val = digest.doFinal(inputBytes, 0);
Please try this and let me know if it works for you.
Original comment by moor...@gmail.com
on 4 Oct 2009 at 4:43
This is not a bug.
Original comment by moor...@gmail.com
on 8 Oct 2009 at 4:37
after this i'm getting this
00:08:17,234 [ERROR] Line 45: The method getBytes() is undefined for the type
String for byte[] pwBytes = passwordString.getBytes();
Original comment by javaSp...@gmail.com
on 29 Sep 2010 at 9:28
javaSparx,
I don't follow you. What is the situation where you're getting that error?
Please post code if possible.
Original comment by moor...@gmail.com
on 29 Sep 2010 at 3:04
Original issue reported on code.google.com by
lloyd.bo...@gmail.com
on 16 Sep 2009 at 12:53