public class CryptoUtils extends Utils
Title: Framework Support Library
Description: Contains encryption-related utilities.
Copyright: Copyright (c) 2010
Company: StreamScape Technologies
Modifier and Type | Class and Description |
---|---|
static interface |
CryptoUtils.HashCalculator |
static class |
CryptoUtils.Sha256FileHashCalculator |
static class |
CryptoUtils.Sha256RandomAccessFileHashCalculator |
DEFAULT_SERIAL_VERSION_ID
Constructor and Description |
---|
CryptoUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
calcSha256Hash(byte[] data) |
static byte[] |
calcSha256Hash(java.io.InputStream is) |
static java.lang.String |
calculateDigest(byte[] data,
java.lang.String algorithm)
Calculates a secure one-way digest from the specified data using the specified algorithm.
|
static java.lang.String |
calculateDigest(java.lang.String key,
java.lang.String value,
java.lang.String algorithm)
Calculates a secure one-way digest from the specified key and value using the specified algorithm.
|
static java.security.MessageDigest |
createSha256Digest() |
static byte[] |
decrypt(byte[] data,
byte[] key) |
static byte[] |
decrypt(byte[] data,
java.security.Key key) |
static java.io.InputStream |
decryptInputStream(java.io.InputStream stream,
javax.crypto.Cipher cipher,
java.security.Key key) |
static java.io.InputStream |
decryptOutputStream(java.io.InputStream stream,
java.security.Key key) |
static byte[] |
encrypt(byte[] data,
byte[] key) |
static byte[] |
encrypt(byte[] data,
java.security.Key key) |
static java.io.OutputStream |
encryptOutputStream(java.io.OutputStream stream,
javax.crypto.Cipher cipher,
java.security.Key key) |
static java.io.OutputStream |
encryptOutputStream(java.io.OutputStream stream,
java.security.Key key) |
static javax.crypto.SecretKey |
generateSecretKey(java.lang.String algorithm,
int keySize) |
bytesToHex, createMap, equals, equals, equalsNullSafe, equalsNullSafe, equalsNullSafe, formatException, formatException, formatException, formatExceptionWithUnrepeatedCauses, formatExceptionWithUnrepeatedCauses, getCause, getCauseAssignable, isEmpty, min, readByteArray, readInt, readLong, recreate, removeAll, sleep, sleepNoInterrupt, toTimeString, unwrapInvokeException, writeInt, writeLong
clone, getSerialVersionUID
public static java.io.OutputStream encryptOutputStream(java.io.OutputStream stream, java.security.Key key) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public static java.io.OutputStream encryptOutputStream(java.io.OutputStream stream, javax.crypto.Cipher cipher, java.security.Key key) throws java.security.InvalidKeyException
java.security.InvalidKeyException
public static java.io.InputStream decryptOutputStream(java.io.InputStream stream, java.security.Key key) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public static java.io.InputStream decryptInputStream(java.io.InputStream stream, javax.crypto.Cipher cipher, java.security.Key key) throws java.security.InvalidKeyException
java.security.InvalidKeyException
public static byte[] encrypt(byte[] data, byte[] key) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public static byte[] encrypt(byte[] data, java.security.Key key) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public static byte[] decrypt(byte[] data, byte[] key) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public static byte[] decrypt(byte[] data, java.security.Key key) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public static javax.crypto.SecretKey generateSecretKey(java.lang.String algorithm, int keySize) throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public static byte[] calcSha256Hash(byte[] data) throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public static java.security.MessageDigest createSha256Digest() throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public static byte[] calcSha256Hash(java.io.InputStream is) throws java.security.NoSuchAlgorithmException, java.io.IOException
java.security.NoSuchAlgorithmException
java.io.IOException
public static java.lang.String calculateDigest(byte[] data, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
data
- the data for digest calculation.algorithm
- the digest algorithm (e.g. MD5, SHA1).java.security.NoSuchAlgorithmException
- if the specified algorithm is not supported.public static java.lang.String calculateDigest(java.lang.String key, java.lang.String value, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
null
it is ignored.
If both key and value are null null
, the method returns null
.key
- the key for digest calculation.value
- the value for digest calculation.algorithm
- the digest algorithm (e.g. MD5, SHA1).java.security.NoSuchAlgorithmException
- if the specified algorithm is not supported.Copyright © 2015-2024 StreamScape Technologies. All rights reserved.