Skip to content

Commit

Permalink
Changes to Podspec
Browse files Browse the repository at this point in the history
  • Loading branch information
littleappdevs committed Feb 15, 2022
1 parent 17ff4b4 commit 2c6c7ea
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
Empty file added LittleSDK.podspec
Empty file.
Binary file added LittleSDK/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions LittleSDK/LittleSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.littlelimited.LittleSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -836,7 +836,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.littlelimited.LittleSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"object": {
"pins": [
{
"package": "abseil",
"repositoryURL": "https://github.com/firebase/abseil-cpp-SwiftPM.git",
"state": {
"branch": null,
"revision": "fffc3c2729be5747390ad02d5100291a0d9ad26a",
"version": "0.20200225.4"
}
},
{
"package": "Alamofire",
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "f82c23a8a7ef8dc1a49a8bfc6a96883e79121864",
"version": "5.5.0"
}
},
{
"package": "BoringSSL-GRPC",
"repositoryURL": "https://github.com/firebase/boringssl-SwiftPM.git",
"state": {
"branch": null,
"revision": "734a8247442fde37df4364c21f6a0085b6a36728",
"version": "0.7.2"
}
},
{
"package": "EasyNotificationBadge",
"repositoryURL": "https://github.com/Minitour/EasyNotificationBadge.git",
"state": {
"branch": null,
"revision": "2774998af193a396b1842c0727fe52c2bd217ae2",
"version": "1.2.5"
}
},
{
"package": "Firebase",
"repositoryURL": "https://github.com/firebase/firebase-ios-sdk.git",
"state": {
"branch": null,
"revision": "5344857522053b5d4403ec8173ec0d23200a97ea",
"version": "8.11.0"
}
},
{
"package": "GoogleAppMeasurement",
"repositoryURL": "https://github.com/google/GoogleAppMeasurement.git",
"state": {
"branch": null,
"revision": "9b2f6aca5b4685c45f9f5481f19bee8e7982c538",
"version": "8.9.1"
}
},
{
"package": "GoogleDataTransport",
"repositoryURL": "https://github.com/google/GoogleDataTransport.git",
"state": {
"branch": null,
"revision": "15ccdfd25ac55b9239b82809531ff26605e7556e",
"version": "9.1.2"
}
},
{
"package": "GoogleMaps",
"repositoryURL": "https://github.com/YAtechnologies/GoogleMaps-SP.git",
"state": {
"branch": null,
"revision": "0e4d95a5844c2a40381bf659fff84cf66699e17b",
"version": "6.0.0"
}
},
{
"package": "GoogleUtilities",
"repositoryURL": "https://github.com/google/GoogleUtilities.git",
"state": {
"branch": null,
"revision": "b3bb0c5551fb3f80ca939829639ab5b093edd14f",
"version": "7.7.0"
}
},
{
"package": "gRPC",
"repositoryURL": "https://github.com/firebase/grpc-SwiftPM.git",
"state": {
"branch": null,
"revision": "fb405dd2c7901485f7e158b24e3a0a47e4efd8b5",
"version": "1.28.4"
}
},
{
"package": "GTMSessionFetcher",
"repositoryURL": "https://github.com/google/gtm-session-fetcher.git",
"state": {
"branch": null,
"revision": "bc6a19702ac76ac4e488b68148710eb815f9bc56",
"version": "1.7.0"
}
},
{
"package": "InputBarAccessoryView",
"repositoryURL": "https://github.com/nathantannar4/InputBarAccessoryView",
"state": {
"branch": null,
"revision": "6d3d205f29b80f8fa9a9616ad801c488293242bf",
"version": "5.4.0"
}
},
{
"package": "IQKeyboardManagerSwift",
"repositoryURL": "https://github.com/hackiftekhar/IQKeyboardManager",
"state": {
"branch": null,
"revision": "474f849accae40fe61b5302d9b057dd48ee073ba",
"version": "6.5.9"
}
},
{
"package": "leveldb",
"repositoryURL": "https://github.com/firebase/leveldb.git",
"state": {
"branch": null,
"revision": "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
"version": "1.22.2"
}
},
{
"package": "MessageKit",
"repositoryURL": "https://github.com/MessageKit/MessageKit",
"state": {
"branch": null,
"revision": "771ffe946acc495a79a122ded921f3460686ee04",
"version": "3.7.0"
}
},
{
"package": "nanopb",
"repositoryURL": "https://github.com/firebase/nanopb.git",
"state": {
"branch": null,
"revision": "7ee9ef9f627d85cbe1b8c4f49a3ed26eed216c77",
"version": "2.30908.0"
}
},
{
"package": "NVActivityIndicatorView",
"repositoryURL": "https://github.com/ninjaprox/NVActivityIndicatorView.git",
"state": {
"branch": null,
"revision": "bcb52371f2259254bac6690f92bb474a61768c47",
"version": "5.1.1"
}
},
{
"package": "Promises",
"repositoryURL": "https://github.com/google/promises.git",
"state": {
"branch": null,
"revision": "611337c330350c9c1823ad6d671e7f936af5ee13",
"version": "2.0.0"
}
},
{
"package": "SDWebImage",
"repositoryURL": "https://github.com/SDWebImage/SDWebImage.git",
"state": {
"branch": null,
"revision": "2c53f531f1bedd253f55d85105409c28ed4a922c",
"version": "5.12.3"
}
},
{
"package": "SwiftProtobuf",
"repositoryURL": "https://github.com/apple/swift-protobuf.git",
"state": {
"branch": null,
"revision": "7e2c5f3cbbeea68e004915e3a8961e20bd11d824",
"version": "1.18.0"
}
},
{
"package": "SwiftMessages",
"repositoryURL": "https://github.com/SwiftKickMobile/SwiftMessages",
"state": {
"branch": null,
"revision": "b29dd21090b708aa0ae9ecbaf6e2d0487028dc3f",
"version": "9.0.6"
}
},
{
"package": "UIView-Shimmer",
"repositoryURL": "https://github.com/omerfarukozturk/UIView-Shimmer.git",
"state": {
"branch": null,
"revision": "6b25069ae46e10295dd9f06e821def70ae197698",
"version": "1.0.4"
}
}
]
},
"version": 1
}
Binary file added LittleSDK/LittleSDK/.DS_Store
Binary file not shown.
105 changes: 105 additions & 0 deletions LittleSDK/LittleSDK/Classes/Encryption/SwiftCrypt.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
//
// Constants.swift
// LittleSDK
//
// Created by Gabriel John on 10/05/2021.
//

import Foundation
import CommonCrypto

struct LittleSDKAES {

// MARK: - Value
// MARK: Private
private let key: Data
private let iv: Data


// MARK: - Initialzier
init?(key: String, iv: String) {
guard key.count == kCCKeySizeAES128 || key.count == kCCKeySizeAES256, let keyData = key.data(using: .utf8) else {
debugPrint("Error: Failed to set a key.")
return nil
}

guard iv.count == kCCBlockSizeAES128, let ivData = iv.data(using: .utf8) else {
debugPrint("Error: Failed to set an initial vector.")
return nil
}


self.key = keyData
self.iv = ivData
}


// MARK: - Function
// MARK: Public
func encrypt(string: String) -> Data? {
return crypt(data: string.data(using: .utf8), option: CCOperation(kCCEncrypt))
}

func decrypt(data: Data?) -> String? {
guard let decryptedData = crypt(data: data, option: CCOperation(kCCDecrypt)) else { return nil }
return String(bytes: decryptedData, encoding: .utf8)
}

func crypt(data: Data?, option: CCOperation) -> Data? {
guard let data = data else { return nil }

let cryptLength = data.count + kCCBlockSizeAES128
var cryptData = Data(count: cryptLength)

let keyLength = key.count
let options = CCOptions(kCCOptionPKCS7Padding)

var bytesLength = Int(0)

let status = cryptData.withUnsafeMutableBytes { cryptBytes in
data.withUnsafeBytes { dataBytes in
iv.withUnsafeBytes { ivBytes in
key.withUnsafeBytes { keyBytes in
CCCrypt(option, CCAlgorithm(kCCAlgorithmAES), options, keyBytes.baseAddress, keyLength, ivBytes.baseAddress, dataBytes.baseAddress, data.count, cryptBytes.baseAddress, cryptLength, &bytesLength)
}
}
}
}

guard UInt32(status) == UInt32(kCCSuccess) else {
debugPrint("Error: Failed to crypt data. Status \(status)")
return nil
}

cryptData.removeSubrange(bytesLength..<cryptData.count)
return cryptData
}
}

func md5Hash (str: String) -> String {
if let strData = str.data(using: String.Encoding.utf8) {
/// #define CC_MD5_DIGEST_LENGTH 16 /* digest length in bytes */
/// Creates an array of unsigned 8 bit integers that contains 16 zeros
var digest = [UInt8](repeating: 0, count:Int(CC_MD5_DIGEST_LENGTH))

/// CC_MD5 performs digest calculation and places the result in the caller-supplied buffer for digest (md)
/// Calls the given closure with a pointer to the underlying unsafe bytes of the strData’s contiguous storage.
strData.withUnsafeBytes {
// CommonCrypto
// extern unsigned char *CC_MD5(const void *data, CC_LONG len, unsigned char *md) --|
// OpenSSL |
// unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) <-|
CC_MD5($0.baseAddress, UInt32(strData.count), &digest)
}

var md5String = ""
/// Unpack each byte in the digest array and add them to the md5String
for byte in digest {
md5String += String(format:"%02x", UInt8(byte))
}

return md5String

}
return ""
}
Binary file added LittleSDK/LittleSDK/LittleSDK.docc/.DS_Store
Binary file not shown.

0 comments on commit 2c6c7ea

Please sign in to comment.