From 88084edb689cb3d088f956f556425fb7ab9ca640 Mon Sep 17 00:00:00 2001 From: rpm-mcarman <65228808+rpm-mcarman@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:24:10 -0400 Subject: [PATCH] Added working encryption --- Sources/App/Controllers/AuthControllers/cntrlUser.swift | 6 +++++- .../Controllers/GlobalFunctions/EncryptionController.swift | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/App/Controllers/AuthControllers/cntrlUser.swift b/Sources/App/Controllers/AuthControllers/cntrlUser.swift index 14061ad..c49b7a8 100644 --- a/Sources/App/Controllers/AuthControllers/cntrlUser.swift +++ b/Sources/App/Controllers/AuthControllers/cntrlUser.swift @@ -42,8 +42,12 @@ struct cntrlUser: RouteCollection { guard let dataQuery = req.parameters.get("credentials") else{ throw Abort(.badRequest) } + let base64Key = "rv0ywT7Ygwh01jP1dQWBP39ogjq5ladO+EoNUGcBVq0=" // Replace with your actual key + guard let keyData = Data(base64Encoded: base64Key) else { + fatalError("Invalid Base64 key data") + } let data = Data(base64Encoded: dataQuery) - let encryptionKey = SymmetricKey(data: "254595778216A74E21211ABCA7AC9".data(using: .utf8)!) + let encryptionKey = SymmetricKey(data: keyData) let sealedBox = try AES.GCM.SealedBox(combined: data!) let decryptedData = try AES.GCM.open(sealedBox, using: encryptionKey) guard let decryptedString = String(data: decryptedData, encoding: .utf8) else{ diff --git a/Sources/App/Controllers/GlobalFunctions/EncryptionController.swift b/Sources/App/Controllers/GlobalFunctions/EncryptionController.swift index a0490df..f917d77 100644 --- a/Sources/App/Controllers/GlobalFunctions/EncryptionController.swift +++ b/Sources/App/Controllers/GlobalFunctions/EncryptionController.swift @@ -6,3 +6,10 @@ // import Foundation +import Crypto + +//struct CustomCrypto{ +// public static func DecryptString(input: String) -> [String]{ +// +// } +//}