Skip to content

Repository files navigation

ABCSecureChannel

ABCSecureChannel for iOS/OS X.

Model

publicstructEncryption{publicletorigin:String // original message
publicletencrypted:String // encrypted string
publicletchannelId:String // shared channel id from server
}publicstructDecryption{publicletencrypted:String // encrypted message
publicletdecrypted:String // decrypted string
publicletchannelId:String // shared channel id from server
}

Example

import ABCSecureChannel
letchannelManager=SecureChannelManager(host:"https://dev-api.id.myabcwallet.com")
// MARK: Encrypt single value
channelManager.encrypt(plain: password){ result inswitch result {case.success(let encryption):
// TODO: use callback Encrypted Model
case .failure(let error):
// TODO: handle Error
}}
// MARK: Encrypt multiple values
lettargets:[String:String]=["password":"Hello","key":"World"]
channelManager.encrypt(targets: targets){ result inswitch result {case.success(let encryption):
// TODO: use callback Decrypted Model
case .failure(let error):
// TODO: handle Error
}}
// MARK: Decrypt single value
channelManager.decrypt(encrypted: message){ result inswitch result {case.success(let decryption):
// TODO: use callback Decrypted Model
case .failure(let error):
// TODO: handle Error
}}
// MARK: Decrypt multiple values
lettargets:[String:String]=["password":"E0QV209EU2g2lK4Mv1k7Xw==","key":"NUzRHR7w71t5l9jeB23Kww=="]
channelManager.decrypt(targets: targets){ result inswitch result {case.success(let decryption):
// TODO: use callback Decrypted Model
case .failure(let error):
// TODO: handle Error
}}
channelManager.channelId(){ result inswitch result {case.success(let channelId):
// ...
case .failure(let error):
// TODO: handle Error
}}

Swift Combine

import ABCSecureChannel
import Combine
letchannelManager=SecureChannelManager(host:"https://dev-api.id.myabcwallet.com")
channelManager
.encrypt(plain: password).flatMap{ encryption in
// TODO: API Call
}
channelManager
.decrypt(encrypted: message).map{ decryption in
// TODO: logic
}
channelManager
.channelId().flatMap{ id in
// TODO: logic
}}

Swift Concurrency

import ABCSecureChannel
letchannelManager=SecureChannelManager(host:"https://dev-api.id.myabcwallet.com")Task{letencryption=tryawait channelManager.encrypt(plain: password)
// TODO: API Call ..
letdecryption=tryawait channelManager.decrypt(encrypted: message)}

About

Secure Channel Library for apple products

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages