[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit Base64.java,1.3,1.4
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-12-24 15:17:21
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv4233/src/com/meterware/httpunit
Modified Files:
Base64.java
Log Message:
Added JavaDoc
Index: Base64.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Base64.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Base64.java 21 Mar 2002 15:44:03 -0000 1.3
+++ Base64.java 24 Dec 2002 15:17:17 -0000 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* Copyright (c) 2000-2002 by Russell Gold
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -19,10 +19,21 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
+
+/**
+ * A utility class to convert to and from base 64 encoding.
+ *
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
+ **/
public class Base64 {
final static String encodingChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ /**
+ * Returns the base 64 encoded equivalent of a supplied string.
+ * @param source the string to encode
+ */
public static String encode( String source ) {
char[] sourceBytes = getPaddedBytes( source );
int numGroups = (sourceBytes.length + 2) / 3;
@@ -60,6 +71,10 @@
}
+ /**
+ * Returns the plaintext equivalent of a base 64-encoded string.
+ * @param source a base 64 string (which must have a multiple of 4 characters)
+ */
public static String decode( String source ) {
if (source.length()%4 != 0) throw new RuntimeException( "valid Base64 codes have a multiple of 4 characters" );
int numGroups = source.length() / 4;
|