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();
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 address@hidden -- address@hidden
</console output>
Sent from the Gnu - Crypto - Discuss forum at Nabble.com: Problem padding