Compare commits
10 Commits
feature/do
...
729812d20b
| Author | SHA1 | Date | |
|---|---|---|---|
| 729812d20b | |||
| 08519d1aca | |||
|
|
7ac2ccb21f | ||
|
|
d2ca6e54d2 | ||
|
|
0eb4f355df | ||
|
|
3e3e181b36 | ||
|
|
175816dff8 | ||
|
|
daae48817a | ||
|
|
241d69ecc1 | ||
|
|
f4fade0442 |
15
Package.resolved
Normal file
15
Package.resolved
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"originHash" : "c64eb123858a637db7dce26475a35db7adb60ead911617c384beba36afa95bc5",
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "lcecryptokitbinary",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://60c260c85d3a2fe840411b0ff98f521b5eca3c56@git.loverde.com.br/Loverde-Company-LTDA/LCECryptoKitBinary.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "2e7850fdb14cacf6bf2eb160f64c3df84cf5b1c4",
|
||||||
|
"version" : "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
|
}
|
||||||
@@ -1,16 +1,33 @@
|
|||||||
// swift-tools-version: 6.0
|
// swift-tools-version: 6.0
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
let isLocalDevelopment = FileManager.default.fileExists(atPath: "../LCECryptoKit/PrivateLib/LCECryptoKitBinary")
|
||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "LCEssentials",
|
name: "LCEssentials",
|
||||||
|
platforms: [
|
||||||
|
.iOS(.v13),
|
||||||
|
.macOS(.v10_15),
|
||||||
|
.tvOS(.v13),
|
||||||
|
.watchOS(.v6)
|
||||||
|
],
|
||||||
products: [
|
products: [
|
||||||
.library(
|
.library(
|
||||||
name: "LCEssentials",
|
name: "LCEssentials",
|
||||||
targets: ["LCEssentials"]),
|
targets: ["LCEssentials"]),
|
||||||
],
|
],
|
||||||
|
dependencies: [
|
||||||
|
.package(
|
||||||
|
url: isLocalDevelopment ?
|
||||||
|
"../LCECryptoKit/PrivateLib/LCECryptoKitBinary" :
|
||||||
|
"https://60c260c85d3a2fe840411b0ff98f521b5eca3c56@git.loverde.com.br/Loverde-Company-LTDA/LCECryptoKitBinary.git",
|
||||||
|
exact: "1.0.0"
|
||||||
|
)
|
||||||
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
name: "LCEssentials"),
|
name: "LCEssentials",
|
||||||
|
dependencies: [.product(name: "LCECryptoKit", package: "lcecryptokitbinary")]),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
41
Sources/LCEssentials/Classes/LCECrypto.swift
Normal file
41
Sources/LCEssentials/Classes/LCECrypto.swift
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2025 Loverde Co.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import LCECryptoKit
|
||||||
|
|
||||||
|
public final class LCECrypto {
|
||||||
|
|
||||||
|
private let hashKey: String
|
||||||
|
|
||||||
|
init(privateKey: String){
|
||||||
|
self.hashKey = privateKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeOTP(email: String, password: String) -> String? {
|
||||||
|
return LCECryptoKit.encodeSeed(email: email, password: password, hashKey: self.hashKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeOTP(_ otpHash: String) -> Bool {
|
||||||
|
LCECryptoKit.decodeSeed(otpKey: otpHash, hashKey: self.hashKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,15 +129,26 @@ public struct API {
|
|||||||
// Add the file
|
// Add the file
|
||||||
let fileName = fileURL.lastPathComponent
|
let fileName = fileURL.lastPathComponent
|
||||||
let mimeType = mimeTypeForPath(path: fileName)
|
let mimeType = mimeTypeForPath(path: fileName)
|
||||||
|
printInfo(title: "Body size before", msg: "\(body.count) bytes")
|
||||||
|
|
||||||
|
let fileData: Data
|
||||||
|
do {
|
||||||
|
fileData = try Data(contentsOf: fileURL)
|
||||||
|
printInfo(title: "Body size after", msg: "\(body.count) bytes")
|
||||||
|
} catch {
|
||||||
|
printError(title: "Upload File", msg: error.localizedDescription)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let fileData = try Data(contentsOf: fileURL)
|
|
||||||
body.append("--\(boundary)\r\n".data(using: .utf8)!)
|
body.append("--\(boundary)\r\n".data(using: .utf8)!)
|
||||||
body.append("Content-Disposition: form-data; name=\"file\"; filename=\"\(fileName)\"\r\n".data(using: .utf8)!)
|
body.append("Content-Disposition: form-data; name=\"file\"; filename=\"\(fileName)\"\r\n".data(using: .utf8)!)
|
||||||
body.append("Content-Type: \(mimeType)\r\n\r\n".data(using: .utf8)!)
|
body.append("Content-Type: \(mimeType)\r\n\r\n".data(using: .utf8)!)
|
||||||
body.append(fileData)
|
let fileDataCopy = Data(fileData)
|
||||||
body.append("\r\n".data(using: .utf8)!)
|
body.append(fileDataCopy)
|
||||||
} catch {
|
let dataUTF8 = "\r\n".data(using: .utf8)!
|
||||||
printError(title: "Upload File", msg: error.localizedDescription)
|
body.append(dataUTF8)
|
||||||
|
printInfo(title: "Body size after", msg: "\(body.count) bytes")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize the request body
|
// Finalize the request body
|
||||||
|
|||||||
Reference in New Issue
Block a user