Class KeyLoader

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

public class KeyLoader extends Object
This class simplifies the process of loading Keys from files
  • Constructor Details

    • KeyLoader

      public KeyLoader()
  • Method Details

    • loadPublicKeyFromFile

      public static PublicKey loadPublicKeyFromFile(Path file) throws IOException
      Loads a Base64 encoded RSA public key from file
      Parameters:
      file - Path of the file containing the Base64 encoded public key
      Returns:
      the public key
      Throws:
      IOException - if the file can not be read
    • loadPrivateKeyFromFile

      public static PrivateKey loadPrivateKeyFromFile(Path file) throws IOException
      Loads a Base64 encoded RSA private key from file
      Parameters:
      file - Path of the file containing the Base64 encoded private key
      Returns:
      the private key
      Throws:
      IOException - if the file can not be read
    • loadPublicKeyFromEncryptedFile

      public static dev.netcode.util.Result<PublicKey> loadPublicKeyFromEncryptedFile(Path file, String password) throws IOException
      Loads a Base64 encoded RSA public key from an encrypted file
      Parameters:
      file - Path of the file containing the Base64 encoded public key
      password - used to decrypt the file
      Returns:
      the public key
      Throws:
      IOException - if the file can not be read
    • loadPrivateKeyFromEncryptedFile

      public static dev.netcode.util.Result<PrivateKey> loadPrivateKeyFromEncryptedFile(Path file, String password) throws IOException
      Loads a Base64 encoded RSA private key from an encrypted file
      Parameters:
      file - Path of the file containing the Base64 encoded private key
      password - used to decrypt the file
      Returns:
      the private key
      Throws:
      IOException - if the file can not be read