Solved: Could not perform unpadding invalid pad byte

by Pete Freitag

When you run into an error like this in ColdFusion, or otherwise using the RSA jSafe CryptoJ java package:

An error occurred while trying to encrypt or decrypt your input string: com.rsa.jsafe.crypto.dr: Could not perform unpadding: invalid pad byte..

It usually means that you are trying to decrypt a value using the wrong encryption key.

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.