Created
May 27, 2012 16:20
-
-
Save mlittle/2814946 to your computer and use it in GitHub Desktop.
Oracle PL/SQL function that adds PKCS #7 padding to the input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE FUNCTION fn_PKCS7_Pad(pData IN RAW, pBlockSize IN PLS_INTEGER) | |
| RETURN RAW | |
| IS | |
| vPadSize PLS_INTEGER; | |
| vPadValue RAW(2); | |
| BEGIN | |
| vPadSize := pBlockSize - MOD(utl_raw.length(pData), pBlockSize); | |
| vPadValue := hextoraw(ltrim(to_char(vPadSize, 'XX'))); | |
| RETURN utl_raw.concat(pData, utl_raw.copies(vPadValue, vPadSize)); | |
| END; | |
| / |
Can this be used with dbms_obfuscation_toolkit.DES3Decrypt?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More details on this function: http://matthewjlittle.com/2011/07/02/plsql-pkcs-7-padding/