Package org.jboss.security
Class Base64Encoder
- java.lang.Object
-
- org.jboss.security.Base64Encoder
-
public final class Base64Encoder extends Object
BASE64 encoder implementation. Provides encoding methods, using the BASE64 encoding rules, as defined in the MIME specification, rfc1521. This class is a modified version based on code obtained from the w3 consortium website, which is subject to their generic copyright notice:- Copyright � [$date-of-software] World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. This program is distributed under the W3C's Software Intellectual Property License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more details.
-
-
Constructor Summary
Constructors Constructor Description Base64Encoder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
encode(byte[] bytes)
Encode the given byte array and return the result as a string.static void
encode(byte[] input, OutputStream out)
Encode the supplied byte array and write the encoded data to the OutputStream out.static void
encode(InputStream in, OutputStream out)
Encodes data from supplied input to output.static String
encode(String input)
Encode the given string,and return the encoded version as a string.static void
main(String[] args)
Run with one argument, prints the encoded version of it.
-
-
-
Method Detail
-
encode
public static void encode(InputStream in, OutputStream out) throws IOException
Encodes data from supplied input to output.- Parameters:
in
- The input stream to be encoded.out
- The output stream, to write encoded data to.- Throws:
IOException
-
encode
public static void encode(byte[] input, OutputStream out) throws IOException
Encode the supplied byte array and write the encoded data to the OutputStream out.- Throws:
IOException
-
encode
public static String encode(String input) throws IOException
Encode the given string,and return the encoded version as a string.- Returns:
- A String, representing the encoded content of the input String.
- Throws:
IOException
-
encode
public static String encode(byte[] bytes) throws IOException
Encode the given byte array and return the result as a string.- Throws:
IOException
-
main
public static void main(String[] args) throws Exception
Run with one argument, prints the encoded version of it. With two, the second is assumed to be the name of a MessageDigest to be applied to the string before encoding (useful for generating password hashes).Alternatively, use the openssl utility, for example:
echo -n "password" | openssl dgst -sha1 -binary | openssl base64
- Throws:
Exception
-
-