public class SsRtbCrypter extends Object
Modifier and Type | Field and Description |
---|---|
private static int |
CIPHERTEXT_SIZE |
private static String |
HMAC_SHA1 |
private static int |
INTEGRITY_SIZE |
private static int |
IV_SIZE |
private Random |
rand |
private static Charset |
US_ASCII |
Constructor and Description |
---|
SsRtbCrypter() |
Modifier and Type | Method and Description |
---|---|
SecretKey |
b64StrToKey(String b64Str) |
long |
decodeDecrypt(String base64Websafe,
SecretKey encryptKey,
SecretKey integrityKey) |
long |
decodeDecrypt(String base64Websafe,
String b64EncryptKey,
String b64IntegrityKey) |
byte[] |
decrypt(byte[] crypted,
SecretKey encryptionKey,
SecretKey integrityKey) |
byte[] |
decrypt(byte[] ciphered,
String b64EncryptKey,
String b64IntegrityKey) |
byte[] |
encrypt(byte[] unciphered,
SecretKey encryptionKey,
SecretKey integrityKey) |
byte[] |
encrypt(byte[] unciphered,
String b64EncryptKey,
String b64IntegrityKey) |
String |
encryptEncode(long value,
SecretKey encryptKey,
SecretKey integrityKey) |
String |
encryptEncode(long value,
String b64EncryptKey,
String b64IntegrityKey) |
SecretKey |
hexStrToKey(String hexKey) |
protected byte[] |
toBytes(long val)
Converts a long to an 8 byte array.
|
protected long |
toLong(byte[] buff)
Converts an array of 8 bytes into a long.
|
private static final Charset US_ASCII
private static final String HMAC_SHA1
private static final int IV_SIZE
private static final int CIPHERTEXT_SIZE
private static final int INTEGRITY_SIZE
private final Random rand
public SecretKey hexStrToKey(String hexKey) throws org.apache.commons.codec.DecoderException
org.apache.commons.codec.DecoderException
public long decodeDecrypt(String base64Websafe, String b64EncryptKey, String b64IntegrityKey) throws SsRtbDecryptingException
SsRtbDecryptingException
public long decodeDecrypt(String base64Websafe, SecretKey encryptKey, SecretKey integrityKey) throws SsRtbDecryptingException
SsRtbDecryptingException
public byte[] decrypt(byte[] ciphered, String b64EncryptKey, String b64IntegrityKey) throws SsRtbDecryptingException
SsRtbDecryptingException
public byte[] decrypt(byte[] crypted, SecretKey encryptionKey, SecretKey integrityKey) throws SsRtbDecryptingException
SsRtbDecryptingException
protected byte[] toBytes(long val)
DataOutputStream.writeLong(long)
.val
- protected long toLong(byte[] buff)
DataInputStream.readLong()
.buff
-