AES
public struct AES
Advanced Encryption Standard (AES)
For testing purpose created a static instance called default
which takes a key of 16 or 32 characters and an iv of 16 characters
for Production try to create your own AES object
var aes: AES? = {
var key128 = "1qaz2wsx3edc4rfv"
let iv = "5tgb6yhn7ujm8ikl"
return AES(key: key128, iv: iv)
}()
-
Data representing key in utf8 format
Declaration
Swift
public let key: Data
-
Data representing iv in utf8 format
Declaration
Swift
public let iv: Data
-
Advanced Encryption Standard, 128-bit block
Declaration
Swift
public var algorithm: CCAlgorithm { get }
-
Perform PKCS7 padding.
Electronic code book mode, default is CBC.
Declaration
Swift
public var options: CCOptions { get }
-
Encrypt option
Declaration
Swift
public var encOption: CCOptions { get }
-
Decrypt option
Declaration
Swift
public var decOption: CCOptions { get }
-
Status where operation completed normally
Declaration
Swift
public var successStatus: UInt32 { get }
-
Evaluate a status, with needed status
Declaration
Swift
public func evaluate(_ current: CCCryptorStatus, with needed: UInt32) -> Bool
Parameters
current
Input status
needed
UInt32 format of a kCC status.
-
Error Class used for AES errors.
Declaration
Swift
public typealias error = Plist.Error
-
Initialize an optional AES object
Can fail to initalize when key characters was not 16 chars or 32 cars, or initial vector
iv
was not 16 chars.Declaration
Swift
public init?(key: String, iv: String)
Parameters
key
Key string in 16 or 32 chars.
iv
Initial vector in 16 chars.
-
Encrypt raw data with kCCEncrypt option, returns encrypted data
Declaration
Swift
public func encrypt(data: Data) -> Data?
Parameters
data
Raw data
-
Decrypt encrypted data with kCCDecrypt option, returns raw data
Declaration
Swift
public func decrypt(data: Data?) -> Data?
Parameters
data
Encrypted data
-
Crypt data whether Encrypted Data or Raw Data with kCCDecrypt or kCCEncrypt option and returns data based on requested option
Declaration
Swift
public func crypt(data: Data?, option: CCOperation) -> Data?
Parameters
data
Encrypted Data or Raw Data
option
kCCDecrypt or kCCEncrypt