public final class Crypto extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CIPHER_KEY_LEN
Use keys of this length for encryption operations
|
static int |
HMAC_SHA1_LEN
Length of HMAC SHA1 output
|
static SecureRandom |
RAND
Use this random number generator instead of creating your own.
|
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
aes128cbcDecrypt(byte[] key,
byte[] cipherText)
AES-128-CBC decryption.
|
static byte[] |
aes128cbcDecryptWithIv(byte[] key,
byte[] iv,
byte[] cipherText,
int offset)
AES-128-CBC decryption with a particular IV.
|
static byte[] |
aes128cbcEncrypt(byte[] key,
byte[] plain)
AES-128-CBC encryption.
|
static byte[] |
aes128cbcEncryptWithIV(byte[] key,
byte[] iv,
byte[] plain)
AES-128-CBC encryption with a given IV.
|
static byte[] |
concat(byte[] a,
byte[] b)
Concatenate two byte arrays.
|
static byte[] |
getRandomBytes(int numBytes)
Returns strong random bytes.
|
static String |
getRandomDigits(int len) |
static String |
getRandomString(int numBytes)
Gets a hex encoded random string.
|
static byte[] |
hmacSha1(byte[] key,
byte[] in)
HMAC sha1
|
static void |
hmacSha1Verify(byte[] key,
byte[] in,
byte[] expected)
Verifies an HMAC SHA1 hash.
|
public static final SecureRandom RAND
public static final int CIPHER_KEY_LEN
public static final int HMAC_SHA1_LEN
public static String getRandomString(int numBytes)
numBytes - number of bytes of randomness.public static String getRandomDigits(int len)
public static byte[] getRandomBytes(int numBytes)
numBytes - number of bytes of randomnesspublic static byte[] hmacSha1(byte[] key,
byte[] in)
throws GeneralSecurityException
key - the key must be at least 8 bytes in length.in - byte array to HMAC.GeneralSecurityExceptionpublic static void hmacSha1Verify(byte[] key,
byte[] in,
byte[] expected)
throws GeneralSecurityException
key - in - expected - GeneralSecurityExceptionpublic static byte[] aes128cbcEncrypt(byte[] key,
byte[] plain)
throws GeneralSecurityException
key - plain - GeneralSecurityExceptionpublic static byte[] aes128cbcEncryptWithIV(byte[] key,
byte[] iv,
byte[] plain)
throws GeneralSecurityException
key - iv - plain - GeneralSecurityExceptionpublic static byte[] aes128cbcDecrypt(byte[] key,
byte[] cipherText)
throws GeneralSecurityException
key - cipherText - GeneralSecurityExceptionpublic static byte[] aes128cbcDecryptWithIv(byte[] key,
byte[] iv,
byte[] cipherText,
int offset)
throws GeneralSecurityException
key - decryption keyiv - initial vector for decryptioncipherText - cipher text to decryptoffset - offset into cipher text to begin decryptionGeneralSecurityExceptionpublic static byte[] concat(byte[] a,
byte[] b)
Copyright © 2007-2012. All Rights Reserved.