+ 1

I find some bug at "Simple text encryption and decryption" program

Hellow everybody. I find some bug at "Simple text encryption and decryption" program posted by SoloLearn. If you try to change "This is awesome" to String text="____"; for instance the code generates ArrayIndexOutOfBoundsException. In case of String text ="\"\"\"'; the string is ofset only with 4, no 5. This is true about all symbols in the end of tample array. I thing the loop at row 38 must be change from if (j <= chars.length - offset) { to if (j < chars.length - offset) { and most immportant the encrypting formula at row 45 plain[i] = chars[j - (chars.length - offset + 1)]; to plain[i] = chars[j - (chars.length - offset )]; and correspondly the decrypting formula at row 62 from cipher[i] = chars[(chars.length - offset +1) + j]; to cipher[i] = chars[(chars.length - offset ) + j]; These changes fix the problem in my view. Sorry for my not fulent english, I hope that SoloLearn will answer here.

19th Oct 2016, 2:30 AM
Ivan Velinov
3 Antworten
+ 2
You are a good Bug Hunter
27th Oct 2016, 3:54 PM
Mihai Dancaescu
Mihai Dancaescu - avatar
+ 1
You are a good Bug Hunter
27th Oct 2016, 3:53 PM
Mihai Dancaescu
Mihai Dancaescu - avatar
+ 1
You are a good Bug Hunter
27th Oct 2016, 3:54 PM
Mihai Dancaescu
Mihai Dancaescu - avatar