package database;

/**
 * Hold and make available credentials to connect to SQL database.
 */
public class ConnectionCredentials {
    private String serverName = "";
    private String username = "";
    private String password = "";
    private final String DATABASE_NAME = "Francis";

    public ConnectionCredentials(String serverName, String username, String password) {
        this.serverName = serverName;
        this.username = username;
        this.password = password;
    }

    @Override
    public String toString() {
        return String.format(
                "serverName: %s | databaseName: %s | username: %s | password: HIDDEN",
                getServerName(),
                getDatabaseName(),
                getUsername()
        );
    }

    /*
    * Field getters and setters
    */
    private String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    private String getDatabaseName() {
        return DATABASE_NAME;
    }

    private String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}

@@ -12,16 +12,111 @@
 abase;%0A%0A
+import javax.crypto.Cipher;%0Aimport javax.crypto.spec.SecretKeySpec;%0Aimport java.security.Key;%0A%0A
 /**%0A * H
@@ -271,27 +271,45 @@
 ate 
+final 
 String 
-username = %22
+DATABASE_NAME = %22Francis
 %22;%0A 
@@ -326,24 +326,24 @@
  String 
-password
+username
  = %22%22;%0A 
@@ -357,46 +357,32 @@
 ate 
-final String DATABASE_NAME = %22Francis%22
+byte%5B%5D encryptedPassword
 ;%0A%0A 
@@ -548,39 +548,597 @@
         
-this.password = passwor
+encryptedPassword = encrypt(password);%0A    %7D%0A%0A    private byte%5B%5D encrypt(String password) %7B%0A        // Encryption code based on%0A        // http://stackoverflow.com/a/32583766/3626537%0A        byte%5B%5D encrypted = %7B%7D;%0A        try %7B%0A            Key passwordKey = new SecretKeySpec(password.getBytes(), %22AES%22);%0A            Cipher cipher = Cipher.getInstance(%22AES%22);%0A            cipher.init(Cipher.ENCRYPT_MODE, passwordKey);%0A            encrypted = cipher.doFinal(password.getBytes());%0A        %7D catch(Exception exc) %7B%0A            exc.printStackTrace();%0A        %7D%0A        return encrypte
 d;%0A    %7D
@@ -1853,32 +1853,117 @@
 sername;%0A    %7D%0A%0A
+    private byte%5B%5D getEncryptedPassword() %7B%0A        return encryptedPassword;%0A    %7D%0A%0A
     public void 
@@ -2005,14 +2005,18 @@
     
-this.p
+encryptedP
 assw
@@ -2021,24 +2021,32 @@
 sword = 
+encrypt(
 password
 ;%0A    %7D%0A
@@ -2033,22 +2033,23 @@
 ypt(password
+)
 ;%0A    %7D%0A%7D%0A

Add encryption to password in ConnectionCredentials