I'm new in terms of encryption and I have to encrypt the data between two Java Spring applications, one have serves as MVC framework and other as Web Service, I'm implementing an asymmetric encryption by generating the private and public key with RSA at the beginning of the deployment cycle and saving the keys in binary files locally in the hard drive but I’m not sure if that is the best way of doing it, and then I have to share the public keys between the two projects automatically but I don’t know how should I do this, I was planning to exchange the keys by sending a petition to the Web Service.
I'm using the KeyPairGenerator
class to get a KeyPair
and writing the PrivateKey
and PublicKey
objects to local disc.