com.monica.javacom.ciphering
Class RSA
java.lang.Object
|
+--com.monica.javacom.ciphering.RSA
- public class RSA
- extends java.lang.Object
Implements an RSA (Rivest-Shamir-Adleman) encoder/decoder, which is a recent standard for public-key-ciphering of digital data.
This object uses an RSAKey as the encoding/decoding key, which is part of an RSAKeyPair, generated by an RSAKeyPairGenerator.
As the main functionality, the coder gets a String which contains the initial data, and returns the coded representation of this String.
- See Also:
RSAKey
,
RSAKeyPair
,
RSAKeyPairGenerator
Constructor Summary |
RSA(RSAKey in_key)
Constructs a new RSA encoder/decoder object. |
Method Summary |
java.lang.String |
decode(java.lang.String text)
Decodes the specified String. |
java.lang.String |
encode(java.lang.String text)
Encodes the specified String. |
RSAKey |
getKey()
Returns the RSAKey of this RSA object. |
void |
setKey(RSAKey in_key)
Sets the RSAKey of this object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RSA
public RSA(RSAKey in_key)
- Constructs a new RSA encoder/decoder object.
- Parameters:
in_key
- the RSAKey that the RSA will use to encode/decode
encode
public java.lang.String encode(java.lang.String text)
throws ZeroLengthStringException
- Encodes the specified String.
- Parameters:
text
- the input text which has to be encoded- Returns:
- the encoded representation of the input text
- Throws:
ZeroLengthStringException
- input string must not be empty
decode
public java.lang.String decode(java.lang.String text)
throws ZeroLengthStringException
- Decodes the specified String.
- Parameters:
text
- the encoded text which must be the result of the encode() function of an RSA object whith the same key, that this RSA is working with.- Returns:
- the decoded representation of the encoded text, the input text of the encoding algorithm
- Throws:
ZeroLengthStringException
- input string must not be empty
getKey
public RSAKey getKey()
- Returns the RSAKey of this RSA object.
- Returns:
- the RSAKey, that this object is working with
setKey
public void setKey(RSAKey in_key)
- Sets the RSAKey of this object.
- Parameters:
in_key
- the new RSAKey that this RSA object should use