Skip to content

Instantly share code, notes, and snippets.

@mlittle
Created May 27, 2012 16:20
Show Gist options
  • Save mlittle/2814946 to your computer and use it in GitHub Desktop.
Save mlittle/2814946 to your computer and use it in GitHub Desktop.
Oracle PL/SQL function that adds PKCS #7 padding to the input
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;
/
@mlittle
Copy link
Author

mlittle commented May 27, 2012

@bnason
Copy link

bnason commented Mar 8, 2019

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