wokier / gwt-crypto

Automatically exported from code.google.com/p/gwt-crypto
8 stars 1 forks source link

Error: java.lang.IndexOutOfBoundsException: srcPos + length must not be greater than src.length #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. create a new GWT project in eclipse (package, org.alfaero.lab2), import
the gwt-crypto-1.0.3.jar into the src tree, modify the Lab.gwt.xml to
include the inherits "com.googlecode.gwt.crypto.Crypto"

2. modify the Lab2.java in org.alfaero.lab2, with the following codes:

  In onModuleLoad(), add the follows:

  byte MyKey[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };

  final TripleDesCipher cip = new TripleDesCipher();
  cip.setKey(MyKey);

  In sendNameToServer(), add below codes:
  try {
     String rEnc = cip.encrypt("ABCDEFG");
  }
  catch (Exception rEx) {
     throw new RuntimeException(rEx);
  }

3. Run the Lab2, copy the URL to the Browser, press "Send" button, the
captioned Exception will be thrown

What is the expected output? What do you see instead?

I expect there should be no error thrown. I tried to remove the above code
segments and the entire project works fine.

What version of the product are you using? On what operating system?

Windows XP SP3
Eclipse 3.5, Java EE IDE Build id: 20100218-1602 (with gpe-e35-latest.zip
as GWT Plug-In for Eclipse)
GWT 2.0.3

Please provide any additional information below.

The entire project, and the stacktrace are zipped and enclosed for your study.

Original issue reported on code.google.com by bio2c...@yahoo.com.hk on 12 Apr 2010 at 2:03

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Have you tried with a longer key?

byte MyKey[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; 

works for me in tests, while your key fails. 

Original comment by moor...@gmail.com on 30 Apr 2010 at 12:07

GoogleCodeExporter commented 9 years ago
After looking at the code, the solution is to use a key between 16 and 24 bytes 
in 
length, inclusive.

Checked in code to enforce this.

Original comment by moor...@gmail.com on 30 Apr 2010 at 12:32

GoogleCodeExporter commented 9 years ago
I am using rather than elipse IDE, Where can I find Lab2.java file? Please help 
me to resolve the same issue.
Thank you.
Ramesh

Original comment by rameshra...@gmail.com on 11 Feb 2011 at 11:36