|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasteasytrade.JRandTest.Algo.Cipher com.fasteasytrade.JRandTest.Algo.RSACrypt
Java RSA algorithm implementation.
2 Sep 2003: Zur Aougav 2 Sep 2003: Copyright (c) 2003 Zur Aougav 2 Sep 2003: New RSA java class. 2 Sep 2003: Use simple securerandom class to generate p & q primes. 2 Sep 2003: Read and write biginteger to/from streams as object or simple outputstream (with length). 2 Sep 2003: Vector encrypt(byte[] message) does not handle the last bytes properly. Buffer is filled with 0. Decryption will have 0 (nulls) at end of decoded string. 3 Sep 2003: Add test in main: Shall I compare thee to a summer's day. Shakespeare. 3 Sep 2003: Add save/loadPublicKey and save/loadPrivateKey. 3 Sep 2003: Add -g option: to generate and print keys. 3 Sep 2003: Add -gs option: to generate and save keys in rsapublic.key and rsaprivate.key. 3 Sep 2003: Add encryptFile(infilename,outfilename) and decryptFile(infilename,outfilename). 4 Sep 2003: Add GZIP support. encryptFileGzip(infilename,outfilename) and decryptFileGzip(infilename,outfilename). 4 Sep 2003: Changed default e=3 to e=65537. 17 Mar 2005: encrypt (0 || random 32 bits || data).
Field Summary | |
(package private) BigInteger |
d
|
(package private) BigInteger |
e
|
(package private) int |
msglen
|
(package private) BigInteger |
n
|
(package private) Random |
rnd
|
Constructor Summary | |
RSACrypt()
Almost null contructor |
Method Summary | |
BigInteger |
decrypt(BigInteger message)
Decrypt one big integer |
void |
decryptFile(String infile,
String outfile)
decrypt infile to outfile. |
void |
decryptFileGzip(String infile,
String outfile)
|
BigInteger |
encrypt(BigInteger message)
Encrypt one big integer |
Vector |
encrypt(byte[] message)
encrypt byte[] and returns vector of bigintegers. |
Vector |
encrypt(byte[] message,
int mlen)
encrypt byte[] and returns vector of bigintegers. |
void |
encryptFile(String infile,
String outfile)
encrypt infile to outfile. |
void |
encryptFileGzip(String infile,
String outfile)
encrypt infile to outfile with compression. |
void |
generateKeys(int bitlen)
Generate public and private keys based on two primes, p and q, we make public (n, e), and private (n, d). |
int |
getMessageLength()
Returns message length in bytes. |
void |
loadPrivateKey(String infilename)
Load private key from file |
void |
loadPublicKey(String infilename)
Load public key from file |
static void |
main(String[] args)
Main to test several options of class |
static BigInteger |
read(DataInputStream in)
Read one big integer from inputstream. |
static BigInteger |
read(ObjectInputStream in)
Read one big integer from inputstream, as java object. |
static BigInteger |
readBigInteger(GZIPInputStream in)
Read one big integer from GZIPinputstream. |
static int |
readInt(GZIPInputStream in)
Read int from GZIPinputstream. |
void |
savePrivateKey(String outfilename)
Save private key to file |
void |
savePublicKey(String outfilename)
Save public key to file |
static void |
test1()
Just testing RSA class |
static void |
usage()
Print usage of main RSA class |
static void |
write(BigInteger v,
DataOutputStream out)
Write one big integer to outputstream, including length. |
static void |
write(BigInteger v,
GZIPOutputStream out)
Write one big integer to GZIPoutputstream, including length. |
static void |
write(BigInteger v,
ObjectOutputStream out)
Write one big integer to outputstream, as java object. |
static void |
write(int v,
GZIPOutputStream out)
Write int to GZIPOutputStream |
Methods inherited from class com.fasteasytrade.JRandTest.Algo.Cipher |
compareBytes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
BigInteger n
BigInteger d
BigInteger e
int msglen
Random rnd
Constructor Detail |
public RSACrypt()
Method Detail |
public void generateKeys(int bitlen)
public BigInteger encrypt(BigInteger message)
public BigInteger decrypt(BigInteger message)
public Vector encrypt(byte[] message)
public Vector encrypt(byte[] message, int mlen)
public void encryptFile(String infile, String outfile) throws IOException
IOException
public void decryptFile(String infile, String outfile) throws IOException
IOException
public void encryptFileGzip(String infile, String outfile) throws IOException
IOException
public void decryptFileGzip(String infile, String outfile) throws IOException
IOException
public int getMessageLength()
public static void write(BigInteger v, DataOutputStream out) throws IOException
IOException
public static void write(BigInteger v, ObjectOutputStream out) throws IOException
IOException
public static void write(int v, GZIPOutputStream out) throws IOException
IOException
public static void write(BigInteger v, GZIPOutputStream out) throws IOException
IOException
public static BigInteger read(DataInputStream in) throws IOException
IOException
public static BigInteger read(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static int readInt(GZIPInputStream in) throws IOException
IOException
public static BigInteger readBigInteger(GZIPInputStream in) throws IOException
IOException
public void savePublicKey(String outfilename) throws IOException
IOException
public void loadPublicKey(String infilename) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public void savePrivateKey(String outfilename) throws IOException
IOException
public void loadPrivateKey(String infilename) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void test1()
public static void usage()
public static void main(String[] args)
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |