public class Security extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
b64decode(byte[] msg,
int msgoffs,
int msglen)
Decode the data using Base64
|
static byte[] |
b64encode(byte[] msg,
int msgoffs,
int msglen)
Encodes the data using Base64
|
static byte[] |
decrypt(byte[] msg)
Perform RSA decryption using current RSA public key
|
static byte[] |
decrypt(byte[] msg,
int msglen,
byte[] pubkey,
int priv)
Perform RSA decryption
|
static byte[] |
decrypt(byte[] msg,
int msglen,
int priv)
Perform RSA decryption using current RSA key
|
static byte[] |
encrypt(byte[] msg)
Perform RSA encryption using current RSA private key
|
static byte[] |
encrypt(byte[] msg,
int msglen,
byte[] pubkey,
int priv)
Perform RSA encryption
|
static byte[] |
encrypt(byte[] msg,
int msglen,
int priv)
Perform RSA encryption using current RSA key
|
static byte[] |
hashMessage(byte[] message)
Computes a SHA-1 hash on the given message.
|
static void |
hashMessage(byte[] msg,
int msgoffs,
int msglen,
byte[] hash,
int hashoffs)
Computes a SHA-1 hash on the given message.
|
static byte[] |
hashMessage256(byte[] message)
Computes a SHA-256 hash on the given message.
|
static void |
hashMessage256(byte[] msg,
int msgoffs,
int msglen,
byte[] hash,
int hashoffs)
Computes a SHA-256 hash on the given message.
|
static byte[] |
messageDigest(byte[] message)
Computes MD5 message digest for the given message.
|
static void |
messageDigest(byte[] msg,
int msgoffs,
int msglen,
byte[] hash,
int hashoffs)
Computes MD5 message digest for the given message.
|
static byte[] |
pubkey()
Obtain internal public key in PEM format.
|
static byte[] |
rc4cipher(byte[] msg,
int msglen,
byte[] key)
Perform RC4 cipher
|
public static final int PUBKEY
public static final int PRIVKEY
public static byte[] messageDigest(byte[] message)
message
- the message to hashpublic static void messageDigest(byte[] msg, int msgoffs, int msglen, byte[] hash, int hashoffs)
msg
- the message to hashmsgoffs
- offset into the message arraymsglen
- length of the message to hashhash
- holds the hash value on return (16 bytes minimum)hashoffs
- offset into the hash value arraypublic static byte[] hashMessage(byte[] message)
message
- the message to hashpublic static void hashMessage(byte[] msg, int msgoffs, int msglen, byte[] hash, int hashoffs)
msg
- the message to hashmsgoffs
- offset into the message arraymsglen
- length of the message to hashhash
- holds the hash value on return (20 bytes minimum)hashoffs
- offset into the hash value arraypublic static byte[] hashMessage256(byte[] message)
message
- the message to hashpublic static void hashMessage256(byte[] msg, int msgoffs, int msglen, byte[] hash, int hashoffs)
msg
- the message to hashmsgoffs
- offset into the message arraymsglen
- length of the message to hashhash
- holds the hash value on return (20 bytes minimum)hashoffs
- offset into the hash value arraypublic static byte[] b64encode(byte[] msg, int msgoffs, int msglen)
msg
- the message to encodemsgoffs
- offset into the message arraymsglen
- length of the messagepublic static byte[] b64decode(byte[] msg, int msgoffs, int msglen)
msg
- the message to decodemsgoffs
- offset into the message arraymsglen
- length of the messagepublic static byte[] rc4cipher(byte[] msg, int msglen, byte[] key)
msg
- the message to encrypt/decryptmsglen
- length of the messagekey
- RC4 key of length less than or equal to 256 bytes (maximum 2048 bits)public static byte[] encrypt(byte[] msg)
msg
- array of bytes to be encryptedpublic static byte[] encrypt(byte[] msg, int msglen, int priv)
msg
- array of bytes to be encryptedmsglen
- count of bytes to encryptpriv
- internal key to use: public (0) or private (1)public static byte[] encrypt(byte[] msg, int msglen, byte[] pubkey, int priv)
msg
- array of bytes to be encryptedmsglen
- count of bytes to encryptpubkey
- RSA public key in PEM format for encryption or null if internal usedpriv
- internal key to use: public (0) or private (1)public static byte[] decrypt(byte[] msg)
msg
- array of bytes to be decryptedpublic static byte[] decrypt(byte[] msg, int msglen, int priv)
msg
- array of bytes to be decryptedmsglen
- count of bytes to decryptpriv
- internal key to use: public (0) or private (1)public static byte[] decrypt(byte[] msg, int msglen, byte[] pubkey, int priv)
msg
- array of bytes to be decryptedmsglen
- count of bytes to decryptpubkey
- RSA public key in PEM format for decryption or null if internal usedpriv
- internal key to use: public (0) or private (1)public static byte[] pubkey()