i am using java encryption package and developed a small program which generates key and encrypts and decrypts the string. when i direct string i gives me values properly(i.e. encrypts and decrypts). But when i retrieve a value from database(mysql) and pass the string for the method the decryption gives me exception. BADPADDING exception. given final block is not padded properly. can somebody suggest how to rectify and padding procedure.