Skip to content

Instantly share code, notes, and snippets.

@mlittle
Created May 27, 2012 16:25
Show Gist options
  • Save mlittle/2814959 to your computer and use it in GitHub Desktop.
Save mlittle/2814959 to your computer and use it in GitHub Desktop.
Oracle PL/SQL function that removes PKCS #7 padding from the input
CREATE OR REPLACE FUNCTION fn_PKCS7_Trim(pData IN RAW)
RETURN RAW
IS
vPadSize PLS_INTEGER;
vPadValue RAW(2);
BEGIN
vPadValue := utl_raw.substr(pData, -1, 1);
vPadSize := to_number(rawtohex(vPadValue), 'XX');
RETURN utl_raw.substr(pData, 1, utl_raw.length(pData) - vPadSize);
END;
/
@mlittle
Copy link
Author

mlittle commented May 27, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment