Class KeyGenerator


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

      Constructors 
      Constructor Description
      KeyGenerator()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean generateKeys​(int size, java.nio.file.Path publicKeyFile, java.nio.file.Path privateKeyFile)
      Generates RSA Keys of given size and saves them to files
      static boolean generateKeys​(int size, java.nio.file.Path publicKeyFile, java.nio.file.Path privateKeyFile, java.lang.String password)
      Generates RSA Keys of given size, encrypts them using AES and saves them to files
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KeyGenerator

        public KeyGenerator()
    • Method Detail

      • generateKeys

        public static boolean generateKeys​(int size,
                                           java.nio.file.Path publicKeyFile,
                                           java.nio.file.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,
                                           java.nio.file.Path publicKeyFile,
                                           java.nio.file.Path privateKeyFile,
                                           java.lang.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