trouble decrypting AES from C# (unsigned byte vs signed byte issue)
843811Apr 6 2009 — edited Apr 7 2009I am trying to decrypt something which was encrypted in C# and I am getting a BadPadding exception, so I started digging a bit deeper and I found that the byte array that C# is using to encrypt is different than the byte array that java is using to decrypt (Note: both byte arrays are generated from a Hex String). This is the byte array that is passed into the SecretKeySpec constructor.
After stepping through the Hex string to byte array conversion, I found that the byte array differed in places where the hex was something like "B3". This should convert to 179 (as is does in c#), but since there are no unsigned bytes in java, I get -77.
So my question is, I am essentially screwed? Is there any way of getting around this (short of changing the key to not use any hex greater than the Byte.MAX_VALUE)?
Thanks.