New encryption routine

Added to make the encryption routine more robust
This commit is contained in:
Keith Armstrong 2024-12-31 08:40:19 -05:00
parent 8cfb65ccd7
commit 9de9f501ef

View File

@ -14,6 +14,7 @@ public class webService {
static Boolean varDebug = false; static Boolean varDebug = false;
static String varKey; static String varKey;
static String varSalt = "1zcHJvdG9ubWFpbC9icmlkZ2UtdjMvdXNlcnMvYnJpZGdlLXZhdWx0LWtleQl0gx";
public static void main(String... argv) throws Exception { public static void main(String... argv) throws Exception {
@ -50,6 +51,7 @@ public class webService {
{ {
String varToStore = secretProcessor.encode(secretProcessor.encrypt(varKey, varToEncrypt)); String varToStore = secretProcessor.encode(secretProcessor.encrypt(varKey, varToEncrypt));
String varChecked = secretProcessor.decrypt(varKey, secretProcessor.decode(varToStore)); String varChecked = secretProcessor.decrypt(varKey, secretProcessor.decode(varToStore));
System.out.println("Clear Text Password : " + varToEncrypt); System.out.println("Clear Text Password : " + varToEncrypt);
System.out.println("Encryption Key : " + varKey); System.out.println("Encryption Key : " + varKey);
System.out.println("Encrypted / Encoded : " + varToStore); System.out.println("Encrypted / Encoded : " + varToStore);
@ -120,8 +122,8 @@ public class webService {
} }
try { try {
byte[] varDecoded = secretProcessor.decode(varPasswordTemp); varPassword = AES256.decrypt(varPasswordTemp, varKey, varSalt);
varPassword = secretProcessor.decrypt(varKey, varDecoded);
} catch (Exception e) { } catch (Exception e) {
debugProcessor.writer(true, "The password could not be decrypted. Please check that the Encryption Key is correct!"); debugProcessor.writer(true, "The password could not be decrypted. Please check that the Encryption Key is correct!");
System.exit(0); System.exit(0);