Encryption is a solved problem. It's really easy to find out how some unbreakable encryptions work. But just because you know doesn't mean you can decrypt anything without the key.
--
You received this message because you are subscribed to the Google Groups "digitalvoice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to digitalvoice+unsubscribe@googlegroups.com.
To post to this group, send email to digita...@googlegroups.com.
Visit this group at http://groups.google.com/group/digitalvoice.
For more options, visit https://groups.google.com/groups/opt_out.
private static KeyPairGenerator keyGen;
private static KeyPair keyPair;
private static PrivateKey privateKey;
private static PublicKey publicKey;
private static PublicKey remotePublicKey;
private static Cipher cipherEncrypt;
private static Cipher cipherDecrypt;
...blah...blah...
codec = new Codec2();
setMode(Codec2.MODE_1300);
try {
cipherEncrypt = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipherDecrypt = Cipher.getInstance("RSA/ECB/PKCS1Padding");
} catch (Exception e) {
System.out.println("Unable to initialize RSA cipher " + e.toString());
System.exit(-1);
}
/*
* Create 512 bit RSA Session Keys
*/
try {
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(512, random);
keyPair = keyGen.generateKeyPair();
privateKey = keyPair.getPrivate();
publicKey = keyPair.getPublic();
} catch (Exception ex) {
System.out.println("Unable to generate RSA key pair " + " " + ex.toString());
System.exit(-1);
}
try {
/*
* Encrypt with remote public key
*/
cipherEncrypt.init(Cipher.ENCRYPT_MODE, remotePublicKey);
...blah...blah..
/*
* Decrypt with local private key
*/
cipherDecrypt.init(Cipher.DECRYPT_MODE, privateKey);
} catch (Exception ex) {
System.out.println("Unable to set cipher modes " + ex.toString());
System.exit(-1);
}
}