From the course: Learn Java Cryptography

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Generating an asymmetric key pair

Generating an asymmetric key pair - Java Tutorial

From the course: Learn Java Cryptography

Generating an asymmetric key pair

- [Instructor] Now that we've completed basic AES encryption using a modern block cipher and a 256-bit key, we will now work on creating an asymmetric key pair so we can do public key, private key encryption. Let's go ahead and navigate into our IDE and I'd like you to create a package in src, main, Java and that package name is going to be com.frankmoley.crypto.asymmetric. Now in our asymmetric package, we're gonna create a new Java class file called AsymmetricEncryptionUtils. Now just like we did before, we're gonna create a private static final string called RSA and we will simply set it equal to the string RSA. So now we can create a public static key pair and that's from java.security and we will name this method generateRSAKeyPair and we will let it throw an exception. You can import that class if need be. Now, very similar to the way we did before, we're gonna create an instance of SecureRandom and this time we…

Contents