Hi, (sorry for my english, im from ARgentine :( )

i have a very hard problem...well i think its hard :(
i dont have a good understanding of cryptography or cipher...i
just wanna do a padding and unpadding text.
im trying to padding a text just like the padding example say...but when
i try to unpadding the text remains padding...anyone can help me please?
Here is my code and my console output.
Like you see, my input and output are padded... what am i doing wrong!!??
------------------
<code>
try {
        IPad padding = PadFactory.getInstance("PKCS7");
        Cipher cipher = getCipher();
        int blockSize = cipher.getBlockSize();
       
    padding.init(blockSize);
    byte[] input = "HOLA MMMMMMUNDO".getBytes();
   
    byte[] pad = padding.pad(input, 0, input.length);    
   
    byte[] pt = new byte[input.length + pad.length];
    byte[] ct = new byte[pt.length];
    byte[] cpt = new byte[pt.length];
    System.arraycopy(input, 0, pt, 0, input.length);
    System.arraycopy(pad, 0, pt, input.length, pad.length);
    int unpad = padding.unpad(cpt, 0, cpt.length);
    byte[] output = new byte[cpt.length - unpad];
    System.arraycopy(cpt, 0, output, 0, output.length);
           
    System.out.println("TEST " + input + " -- " + output);
</code>
<console output>
TEST [EMAIL PROTECTED] -- [EMAIL PROTECTED]
</console output>

Sent from the Gnu - Crypto - Discuss forum at Nabble.com:
Problem padding
_______________________________________________
gnu-crypto-discuss mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnu-crypto-discuss

Reply via email to