From the course: Learn Java Cryptography
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Performing asymmetric encryption in Java - Java Tutorial
From the course: Learn Java Cryptography
Performing asymmetric encryption in Java
- [Narrator] Now that we have a key pair, it's time to implement our encryption and decryption routines using RSA. Let's jump back into our IDE and open up source main Java. And now, this time, our asymmetric package and open up our asymmetric encryption utils. Now to this class, let's go ahead and add a method. Public static byte array called performRSAEncryption, and we will pass it a string in a plain text, and a private key. And this method will throw an exception. Now much like we saw for the symmetric routine, we are gonna create an instance of a cipher, cipher.getInstance, and we're gonna pass it our RSA algorithm. Now this time there's no padding or CBC because it's not a block cipher, there's no padding, we don't need to deal with any of that this time. But we will go ahead and create a cipher.init, using the encrypt mode, and our private key. And now our final step here is to return the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.