dmc
Class RSA

java.lang.Object
  |
  +--dmc.RSA

public class RSA
extends java.lang.Object

Implementation of the Rivest, Shamir, Adleman algorithm for asymmetric cryptography.


Constructor Summary
RSA(int bitlen)
          Generates private/public key pair of lenth bitlen.
 
Method Summary
 java.lang.String decrypt(java.math.BigInteger msg)
          Decrypts msg using our private key.
 java.lang.String encrypt(java.math.BigInteger msg)
          Encrypts msg using our public key.
 java.lang.String encrypt(java.math.BigInteger msg, java.lang.String publicKey)
          Overloaded version of encrypt to encrypt with an arbitrary public key in the format "e n", such as those produced by getPublicKey().
 java.lang.String getPublicKey()
          Returns this public key in the form "e n".
 java.lang.String sign(java.math.BigInteger msg)
          Signs msg using our private key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSA

public RSA(int bitlen)
Generates private/public key pair of lenth bitlen.

Method Detail

encrypt

public java.lang.String encrypt(java.math.BigInteger msg)
Encrypts msg using our public key.

Parameters:
msg - Cleartext to encrypt.
Returns:
Encrypted version of msg as a hextbin string.

decrypt

public java.lang.String decrypt(java.math.BigInteger msg)
Decrypts msg using our private key.

Parameters:
msg - Ciphertext to be decrypted.
Returns:
Clear text version of msg as a hextbin string.

sign

public java.lang.String sign(java.math.BigInteger msg)
Signs msg using our private key.

Parameters:
msg - Cleartext to signed.
Returns:
Signed version of msg as a hextbin string.

getPublicKey

public java.lang.String getPublicKey()
Returns this public key in the form "e n".

Returns:
Our public key in the form "e n" as a hextbin string.

encrypt

public java.lang.String encrypt(java.math.BigInteger msg,
                                java.lang.String publicKey)
Overloaded version of encrypt to encrypt with an arbitrary public key in the format "e n", such as those produced by getPublicKey().

Parameters:
msg - Cleartext to be encrypted.
publicKey - Public key used to encrypt, in the form "e n" as a hexbin string.
Returns:
Cphertext version of msg as a hexbin string.