Android-PHP-Encrypt-Decrypt icon indicating copy to clipboard operation
Android-PHP-Encrypt-Decrypt copied to clipboard

Can't encrypt unicode string - Java

Open langhoangal opened this issue 10 years ago • 3 comments

Hi,

I have try to use your code to encrypt utf8 string but got an errr: javax.crypto.IllegalBlockSizeException: data not block size aligned.

Could you help to fix, please?

langhoangal avatar Mar 19 '14 16:03 langhoangal

Hello, Does it happen every time you try or with an specific string?

serpro avatar Mar 19 '14 16:03 serpro

Hi,

It happen anytime i try to encrypt the utf8 string. For ex, you can try to encrypt some english phonetic: ˌdef.ɪˈnɪʃ.ən, helˈəʊ

"javax.crypto.IllegalBlockSizeException: data not block size aligned. at com.android.org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(JCEBlockCipher.java:697)"

Many thanks.

langhoangal avatar Mar 19 '14 16:03 langhoangal

Same here, I tried all sorts of ASCII type strings, and they all work. As soon as I type in one UTF-8 character, I get ----------java.lang.Exception: [encrypt] error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:data not multiple of block length ------------ (I must use UTF-8 as my customers speak Hebrew). I am completely flustered and would greatly appreciate it if you had some insight as to how to make it work with UTF-8.

ShalevApps avatar Jul 17 '15 00:07 ShalevApps