Re: problem encrypting data (AES_ENCRYPT/AES_DECRYPT) [message #181758 is a reply to message #181757] |
Thu, 30 May 2013 07:46 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Wed, 29 May 2013 23:28:32 -0700, ViVi wrote:
> I've not been able to track down WHEN it fails, but some strings
> everytime fail, other strings are OK.
How long are the strings that fail - I seem to recall that aes works on
128 bit chunks - so multiples of 16 bytes.
One padding scheme I have seen uses n digits of hex character n as
padding, with 16 wrapping to 0, so for example if the data is a multiple
of 16 bytes, the last 16 bytes are 0, but then if the length of the data
mod 16 is:
1 - 15 * f
2 - 14 * e
............
15 - 1 * 1
0 - 16 * 0
Then after you decrypt, remove the padding chars, given that the last
char tells you how much padding there is.
> OK are .... almost all the following string doppio " apice FAILS
> everytime.
> I've tried defining the DB field (catName) VARCHAR or BINARY to no
> avail.
Also, there's a suggestion elsewhere that I googled that the sql data
field should be varbinary or blob. Is it possible that your encrypted
data is longer than your fixed width field, or in some cases not
compatible with varchar?
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|