Ver código fonte

Added working encryption

main
rpm-mcarman 2 anos atrás
pai
commit
88084edb68
2 arquivos alterados com 12 adições e 1 exclusões
  1. +5
    -1
      Sources/App/Controllers/AuthControllers/cntrlUser.swift
  2. +7
    -0
      Sources/App/Controllers/GlobalFunctions/EncryptionController.swift

+ 5
- 1
Sources/App/Controllers/AuthControllers/cntrlUser.swift Ver arquivo

@@ -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{


+ 7
- 0
Sources/App/Controllers/GlobalFunctions/EncryptionController.swift Ver arquivo

@@ -6,3 +6,10 @@
//

import Foundation
import Crypto

//struct CustomCrypto{
// public static func DecryptString(input: String) -> [String]{
//
// }
//}

Carregando…
Cancelar
Salvar