[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GNU Crypto] Problem padding
From: |
Martin Egholm Nielsen |
Subject: |
Re: [GNU Crypto] Problem padding |
Date: |
Mon, 12 Dec 2005 20:10:03 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.6) Gecko/20050319 |
Hello Gaston,
Hi, (sorry for my english, im from ARgentine :( )
Your english is fine!
i dont have a good understanding of cryptography or cipher...i
That's not the problem - it's much more fundamental...
Here is my code and my console output.
Like you see, my input and output are padded... what am i doing wrong!!??
--- 8< 8< 8< ---
byte[] input = "HOLA MMMMMMUNDO".getBytes();
--- 8< 8< 8< ---
byte[] output = new byte[cpt.length - unpad];
--- 8< 8< 8< ---
System.out.println("TEST " + input + " -- " + output);
TEST address@hidden -- address@hidden
That's as expected. The out you are seeing is '[' to indicate you're
printing an array. 'B' to indicate it's a byte-array, and "@?????" to
indicate the address in memory of the byte-array.
The "problem" is that Java does not do "auto-formatting" of byte-arrays
- so that System.out.println( byteArray ); does not produce the string
you expect. Instead, either do this:
System.out.println( new String(input) );
or print it manually:
for ( int i = 0; i < input.length; i++ )
{
System.out.print( input[ i ] );
} // for
System.out.println();
Try that,
Martin Egholm