public final class Base64Encoder extends Object
Constructor and Description |
---|
Base64Encoder() |
Modifier and Type | Method and 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.
|
public static void encode(InputStream in, OutputStream out) throws IOException
in
- The input stream to be encoded.out
- The output stream, to write encoded data to.IOException
public static void encode(byte[] input, OutputStream out) throws IOException
IOException
public static String encode(String input) throws IOException
IOException
public static String encode(byte[] bytes) throws IOException
IOException
public static void main(String[] args) throws Exception
Alternatively, use the openssl utility, for example:
echo -n "password" | openssl dgst -sha1 -binary | openssl base64
Exception
Copyright © 2018 JBoss by Red Hat. All rights reserved.