@Beta public class CryptoStreams extends Object
ByteStreams
Constructor and Description |
---|
CryptoStreams() |
Modifier and Type | Method and Description |
---|---|
static String |
base64(byte[] in) |
static byte[] |
base64(String in)
decodes base 64 encoded string, regardless of whether padding
'=' padding is present. |
static byte[] |
base64Decode(com.google.common.io.InputSupplier<? extends InputStream> supplier)
Computes and returns the unencoded value for an input stream which is
encoded in Base64.
|
static String |
base64Encode(com.google.common.io.InputSupplier<? extends InputStream> supplier)
Computes and returns the base64 value for a supplied input stream.
|
static String |
base64Url(byte[] in)
encodes value substituting
'-' and '_' for '+' and '/' ,
and without adding trailing '=' padding. |
static byte[] |
digest(com.google.common.io.InputSupplier<? extends InputStream> supplier,
MessageDigest md)
Computes and returns the Digest value for a supplied input stream.
|
static String |
hex(byte[] in) |
static byte[] |
hex(String s) |
static byte[] |
hexDecode(com.google.common.io.InputSupplier<? extends InputStream> supplier)
Computes and returns the unencoded value for an input stream which is
encoded in hex.
|
static String |
hexEncode(com.google.common.io.InputSupplier<? extends InputStream> supplier)
Computes and returns the hex value for a supplied input stream.
|
static byte[] |
mac(com.google.common.io.InputSupplier<? extends InputStream> supplier,
Mac mac)
Computes and returns the MAC value for a supplied input stream.
|
static String |
macBase64(com.google.common.io.InputSupplier<? extends InputStream> supplier,
Mac mac)
Computes and returns the MAC value for a supplied input stream.
|
static byte[] |
md5(byte[] in) |
static byte[] |
md5(com.google.common.io.InputSupplier<? extends InputStream> supplier)
Computes and returns the MD5 value for a supplied input stream.
|
static String |
md5Base64(com.google.common.io.InputSupplier<? extends InputStream> supplier) |
static String |
md5Hex(com.google.common.io.InputSupplier<? extends InputStream> supplier) |
static String |
md5Hex(String in) |
static byte[] |
sha1(byte[] in) |
static byte[] |
sha1(com.google.common.io.InputSupplier<? extends InputStream> supplier)
Computes and returns the SHA1 value for a supplied input stream.
|
public static String hex(byte[] in)
public static byte[] hex(String s)
public static String base64(byte[] in)
@Beta public static String base64Url(byte[] in)
'-' and '_'
for '+' and '/'
,
and without adding trailing '='
padding.
public static byte[] base64(String in)
'='
padding is present.
Note this seamlessly handles the URL-safe case where '-' and '_'
are substituted for '+' and '/'
.public static String md5Hex(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
public static String md5Base64(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
public static String macBase64(com.google.common.io.InputSupplier<? extends InputStream> supplier, Mac mac) throws IOException
supplier
- the input stream factorymac
- the mac objectMac.doFinal()
after updating the mac object
with all of the bytes in the stream and encoding in Base64IOException
- if an I/O error occurspublic static byte[] digest(com.google.common.io.InputSupplier<? extends InputStream> supplier, MessageDigest md) throws IOException
supplier
- the input stream factorymd
- the digest objectMessageDigest.digest()
after updating the
digest object with all of the bytes in the streamIOException
- if an I/O error occurspublic static byte[] sha1(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
digest(com.google.common.io.InputSupplier<? extends java.io.InputStream>, java.security.MessageDigest)
to be more efficient.supplier
- the input stream factoryMessageDigest.digest()
after updating the
sha1 object with all of the bytes in the streamIOException
- if an I/O error occurspublic static byte[] sha1(byte[] in)
public static byte[] md5(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
digest(com.google.common.io.InputSupplier<? extends java.io.InputStream>, java.security.MessageDigest)
to be more efficient.supplier
- the input stream factoryMessageDigest.digest()
after updating the
md5 object with all of the bytes in the streamIOException
- if an I/O error occurspublic static byte[] md5(byte[] in)
public static byte[] mac(com.google.common.io.InputSupplier<? extends InputStream> supplier, Mac mac) throws IOException
supplier
- the input stream factorymac
- the mac objectMac.doFinal()
after updating the mac object
with all of the bytes in the streamIOException
- if an I/O error occurspublic static String base64Encode(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
supplier
- the input stream factoryIOException
- if an I/O error occurspublic static byte[] base64Decode(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
supplier
- the input stream factoryIOException
- if an I/O error occurspublic static String hexEncode(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
supplier
- the input stream factoryIOException
- if an I/O error occurspublic static byte[] hexDecode(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
supplier
- the input stream factoryIOException
- if an I/O error occursCopyright © 2009-2013 jclouds. All Rights Reserved.