Class RSA

java.lang.Object
  |
  +--RSA

public class RSA
extends java.lang.Object

Program to encrypt and decrypt files using the RSA algorithm. This program accepts arguments from the command line and can be run in 3 ways:

RSA uses the functions implemented in class Math. The keys are large prime of 1024 bits.

Author:
E.Lemonnier & E.Nordenstam

Field Summary
static int SIZE_KEY
           
 
Constructor Summary
RSA()
           
 
Method Summary
static java.math.BigInteger decrypt(java.math.BigInteger cypher, java.math.BigInteger key, java.math.BigInteger modulus)
          Decrypt a message with RSA.
static java.math.BigInteger encrypt(java.math.BigInteger message, java.math.BigInteger key, java.math.BigInteger modulus)
          Encrypt a message with RSA.
static java.math.BigInteger[] keys()
          Generate a pair of private and public keys, and a modulus.
static void main(java.lang.String[] arg)
          Crypt/Decrypt a file, or generate keys for a user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE_KEY

public static final int SIZE_KEY
Constructor Detail

RSA

public RSA()
Method Detail

main

public static void main(java.lang.String[] arg)
Crypt/Decrypt a file, or generate keys for a user. See on top of this page for a detailed description.
Parameters:
see - the description above.

encrypt

public static java.math.BigInteger encrypt(java.math.BigInteger message,
                                           java.math.BigInteger key,
                                           java.math.BigInteger modulus)
Encrypt a message with RSA. In fact compute message ^ key mod modulus.

Parameters:
message - the message to encrypt.
key - the key used to crypt the message.
modulus - key modulus.
Returns:
the encoded message.

decrypt

public static java.math.BigInteger decrypt(java.math.BigInteger cypher,
                                           java.math.BigInteger key,
                                           java.math.BigInteger modulus)
Decrypt a message with RSA. In fact compute cypher ^ key mod modulus.

Parameters:
cypher - the cypher to decrypt.
key - the key used to crypt the message.
modulus - key modulus.
Returns:
the decrypted message.

keys

public static java.math.BigInteger[] keys()
Generate a pair of private and public keys, and a modulus. The result is an array of BigIntegers of this form: [private_key, public_key, modulus].

Returns:
the 2 keys and the modulus.