You don't tell us what's happening, or in which line of code it's happening, but usually this exception is caused by treating encrypted data (which is binary data) as character data (by storing it in a String object). The code seems to be doing exactly that.