Created
May 27, 2012 16:35
-
-
Save mlittle/2814993 to your computer and use it in GitHub Desktop.
Test code for my PL/SQL PKCS #7 Pad/Trim functions
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
| DECLARE | |
| PROCEDURE sp_test_pkcs7 (pData IN RAW, pBlockSize IN PLS_INTEGER) | |
| IS | |
| vInData RAW(100); | |
| vDataPadded RAW(100); | |
| vDataTrimmed RAW(100); | |
| BEGIN | |
| vInData := hextoraw(pData); | |
| vDataPadded := fn_pkcs7_pad(vInData, pBlockSize); | |
| vDataTrimmed := fn_pkcs7_trim(vDataPadded); | |
| dbms_output.put_line('------------------------------------'); | |
| dbms_output.put_line('IN: ' || rawtohex(vInData)); | |
| dbms_output.put_line('BLOCK SIZE: ' || pBlockSize); | |
| dbms_output.put_line('PADDED: ' || rawtohex(vDataPadded)); | |
| dbms_output.put_line('TRIMMED: ' || rawtohex(vDataTrimmed)) ; | |
| dbms_output.put_line('------------------------------------'); | |
| END; | |
| BEGIN | |
| sp_test_pkcs7('AABBCC', 8); --3 bytes of data | |
| sp_test_pkcs7('AABBCCDDEEFF', 8); --6 byes of data | |
| sp_test_pkcs7('AABBCCDDEEFFAABB', 8); --8 bytes of data | |
| END; | |
| / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Function Gists:
fn_pkcs7_pad: https://gist.github.com/2814946
fn_pkcs7_trim: https://gist.github.com/2814959
More info on this gist: http://matthewjlittle.com/2011/07/02/plsql-pkcs-7-padding/