Search code examples
javaalgorithmcryptographyprivate-keypublic-key

What cryptographic algorithms should I use to encrypt data using private key and decrypt data using public key?


On RSA cryptographic algorithm, the private key is used to decrypt and public key is used to encrypt data. however I'd like an algorithm to:

  1. Generate private key based on specific data so we can recover it later
  2. Generate public key based on private key
  3. Encrypt data using private key
  4. Decrypt data using public key

What algorithms should I use and is there a java implementation for this?


Solution

  • Step 1 is probably a bad idea unless your seed data has at least as much entropy as the private key. But then, it is equally difficult to store/remember than the private key itself.

    Are you sure you are looking for encryption? Your steps 3 and 4 look more like you actually want a signature.