Db2 – Encrypt data with DES_CBC_PKCS5 in DB2

cryptographydb2oracleplsql

I am using encryption algo DES/CBC/PKCS5Padding. How do I encrypt data using this in DB2?

In Pl/SQL I used DBMS_CRYPTO package with DES_CBC_PKCS5 from DBMS_CRYPTO Block Cipher Suites – https://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_crypto.htm

Version is DB2 v10.5.0.5 and it will run on a Linux box. Distro may be different. Query – SELECT service_level, fixpack_num FROM TABLE (sysproc.env_get_inst_info());

Best Answer

DB2 does not implement the DBMS_CRYPTO module in its Oracle compatibility code. DB2 does still offer the ENCRYPT() and DECRYPT() UDFs, but I would recommend against these as they use a weak encryption algorithm and require the use of passwords in SQL.

So, you would have to implement your own solution (via UDFs) for application-level encryption like this.

It might make more sense to implement this in your application code rather than in the database to avoid having to send encryption keys across the wire to the DBMS. This would certainly be a more platform-independent solution.