Also, this little test exercises the encode/decode methods pretty
heavily. This should be turned into a mauve test by someone motivated...
import gnu.java.util.Base64;
import java.util.Random;
class foo
{
public static void main(String[] a) throws Throwable
{
Random r = new Random();
for (int i = 0; i < 80; i++)
{
System.out.println((i+1) + " of 80...");
for (int j = 1; j <= 256; j++)
{
byte[] b = new byte[j];
r.nextBytes(b);
for (int k = 1; k < j; k++)
{
String s = Base64.encode(b, k, b.length - k, i);
byte[] b2 = Base64.decode(s);
for (int l = 0; l < j - k; l++)
{
if (b2[l] != b[k+l])
System.err.println("FAIL! "+i+":"+j+":"+k+":"+l);
}
}
}
}
}
}
On Jan 31, 2007, at 7:40 PM, Casey Marshall wrote:
I'm checking this in.
This removes two of the four Base-64 classes we have in Classpath
(the last one is stream-based, so I'm not going to muck with it
just yet) and updates the code to use the one implementation
everywhere.
I'm using the version that I wrote (since I volunteered to do this,
I assumed veto power over which version to use ;-), which was in
gnu.javax.net.ssl. I've moved that class to gnu.java.util.Base64,
so if you have Base-64 encoding needs, use that one from now on!
2007-01-31 Casey Marshall <[EMAIL PROTECTED]>
* gnu/javax/net/ssl/Base64.java: move to `gnu/java/util/Base64.java.'
* gnu/javax/net/ssl/PrivateCredentials.java: clean up unused imports.
(add): use `gnu.java.util.Base64.'
* gnu/java/net/protocol/http/Request.java (authenticate): use
`gnu.java.util.Base64.'
* tools/gnu/classpath/tools/jarsigner/HashUtils.java (hashStream):
likewise.
* tools/gnu/classpath/tools/keytool/CertReqCmd.java (start):
likewise.
* tools/gnu/classpath/tools/keytool/ExportCmd.java (start): likewise.
* tools/gnu/classpath/tools/keytool/ListCmd.java (printRFC1421):
likewise.
* gnu/java/net/Base64.java: removed.
* gnu/java/security/util/Base64.java: removed.
Cheers.
<base64.patch>