Class KeyGenerator

java.lang.Object
dev.netcode.security.encryption.KeyGenerator

public class KeyGenerator extends Object
This class can be used to generate RSA cryptographic keys and safe them to file
See Also:
RSAEncrypter
  • Constructor Details

    • KeyGenerator

      public KeyGenerator()
  • Method Details

    • generateKeys

      public static boolean generateKeys(int size, Path publicKeyFile, Path privateKeyFile)
      Generates RSA Keys of given size and saves them to files
      Parameters:
      size - of the keys (the bigger, the more secure)
      publicKeyFile - Path to the file the public key will be saved to. File will be created if it doesn't already exist
      privateKeyFile - Path to the file the private key will be saved to. File will be created if it doesn't already exist
      Returns:
      true if everything was completed successfully. false otherwise
    • generateKeys

      public static boolean generateKeys(int size, Path publicKeyFile, Path privateKeyFile, String password)
      Generates RSA Keys of given size, encrypts them using AES and saves them to files
      Parameters:
      size - of the keys (the bigger, the more secure)
      publicKeyFile - Path to the file the public key will be saved to. File will be created if it doesn't already exist
      privateKeyFile - Path to the file the private key will be saved to. File will be created if it doesn't already exist
      password - to be used to encrypt the keys
      Returns:
      true if everything was completed successfully. false otherwise