|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.mfwk.security.crypto.MfCrypto
This class is used to encrypt and decrypt blocs of data using the DES algorithm.
The key management can be managed by the class itself (by providing a file path which
contains the key)
or can be handled by the caller (by providing the key as a SecretKey object or a byte[]).
Constructor Summary | |
MfCrypto()
Creates a new instance of MfCrypto |
|
MfCrypto(byte[] k)
Creates a new instance of MfCrypto and initialises the secret key with the argument |
|
MfCrypto(javax.crypto.SecretKey k)
Creates a new instance of MfCrypto and initialises the secret key with the argument |
Method Summary | |
byte[] |
decrypt(byte[] buf)
Takes a byte array as input and return a byte array which is decrypted using the symetric key |
byte[] |
encrypt(byte[] buf)
Takes a byte array as input and return a byte array which is encrypted using the symetric key |
byte[] |
getKeyBytes()
Get the key as a byte[] |
javax.crypto.SecretKey |
getKeyObject()
Get the key as Key object |
void |
setKey(byte[] keybuf)
sets the key with the argument |
void |
setKey(javax.crypto.SecretKey k)
sets the key with the argument |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MfCrypto()
public MfCrypto(byte[] k) throws java.security.InvalidKeyException
k
- The key as a byte array.
java.security.InvalidKeyException
- if the key is null or invalid for DES algorithmpublic MfCrypto(javax.crypto.SecretKey k) throws java.security.InvalidKeyException
k
- The key as a SecretKey object.Method Detail |
public void setKey(javax.crypto.SecretKey k) throws java.security.InvalidKeyException
k
- The key as a SecretKey object.
java.security.InvalidKeyException
public void setKey(byte[] keybuf) throws java.security.InvalidKeyException
keybuf
- the key as a byte array.
java.security.InvalidKeyException
- if the key is null or invalid for DES algorithmpublic javax.crypto.SecretKey getKeyObject()
public byte[] getKeyBytes()
public byte[] encrypt(byte[] buf) throws java.security.InvalidKeyException
buf
- The buffer to encrypt.
java.security.InvalidKeyException
- if the key is null (not initialised) or invalid for DES algorithmpublic byte[] decrypt(byte[] buf) throws java.security.InvalidKeyException
buf
- The buffer to decrypt.
java.security.InvalidKeyException
- if the key is null (not initialised) or invalid for DES algorithm
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |