Swift HybridCrypto is simple customizable implementation of hybrid cryptography (AES+RSA+Hash) recommended by OWASP.

Overview

HybridCrypto (Swift)

HybridCrypto is simple implementation of hybrid cryptography following recommendations by OWASP.

Prerequisites:

  • Minimum iOS SDK: 10.0

Usage

Step 1: Add this package to our Swift project via Swift Package Manager (SPM)

https://github.com/UTNGYPisal/HybridCrypto

Step 2: Import package to classes you need to work with encryption

import HybridCrypto

Step 3: Initialize HybridCrypto in your AppDelegate

let publicKeyPlain = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvTtZxoq7IKTwRkADtWix\n" +
"Ryv/CHKK+skNlMMV5G+om75HgHUo8AOzHnj9yUvhcm8Maz46ukxiZsvDPgExu9N1\n" +
"agEm9HHJEZg1VN+2dT+JojODuC3qkF7o94duchQX44gPjyIBEE/113E6fS51SGGm\n" +
"WYrCapSYjNRubB97O1WPm/2nK+A/m9KTtCuIZMp4i/qe4mXCLMRepFO2ORBLD5Ac\n" +
"RU+/tF15IruvaBhZezY+IX571yRao3ZLlVBJtZKU7SHp5udxQ0daRxtsVc9aloC3\n" +
"TRRL8RvFjHyg7V+uSHkg6cN4IIMrTnkwVkn+7BE9KrT7tY8yEkSE8W4WVCDChIRf\n" +
"FwIDAQAB"
HybridCrypto.initialize(with: Configuration.defaultCofig, publicKeyPlain: publicKeyPlain)

Step 4 (Final): Use it wherever you want

do {
    let result = try HybridCrypto.shared.encrypt(message: "Hello")
    print(result.httpParams)
} catch  let err {
    print("Error: \(err)")
}

Result

Once encryption is successful, you'll get a Http-friendly result object

public struct HttpFriendlyResult : Codable {
    let requestPassword: String
    let iv: String
    let salt: String
    let responsePassword: String
    let encryptedData: String
    let signature: String
}
You might also like...
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.

KeychainAccess KeychainAccess is a simple Swift wrapper for Keychain that works on iOS and OS X. Makes using Keychain APIs extremely easy and much mor

A simple Swift Keychain Wrapper for iOS, watchOS, and OS X.

Latch A simple Swift 2.0 Keychain Wrapper for iOS, watchOS 2, and OS X. Usage A proper example of how to use Latch can be seen in the tests. import La

A simple wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.

SwiftKeychainWrapper A simple wrapper for the iOS / tvOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift. Prov

Very simple swift wrapper for Biometric Authentication Services (Touch ID) on iOS.

SimpleTouch Very simple swift wrapper for Biometric Authentication Services (Touch ID) on iOS. Sample Project There is a SimpleTouchDemo target define

A super simple tool for macOS Swift developers to check validity of a Gumroad-issued software license keys

Gumroad License Validator Overview A super simple tool for macOS Swift developers to check validity of a Gumroad-issued software license keys Requirem

Simple Objective-C wrapper for the keychain that works on Mac and iOS

SAMKeychain SAMKeychain is a simple wrapper for accessing accounts, getting passwords, setting passwords, and deleting passwords using the system Keyc

Simple command line to generate random password.

pwgen Simple command line to generate random password. ➜ Bootstrap pwgen n5aR[[email protected]@fj ➜ Bootstrap pwgen 32 f0)th54[wpX.Zf99nj

A really simple key-value wrapper for keychain.

PlainKeychain A really simple key-value wrapper for keychain. Features ✅ Key-value pairs using kSecClassGenericPassword. ❌ Internet passwords (kSecCla

Simple class to check if app has been cracked, being debugged or enriched with custom dylib

iOS-App-Security-Class Simple class to check if iOS app has been cracked, being debugged or enriched with custom dylib and as well detect jailbroken e

Releases(1.0.1)
Owner
UTNGY Pisal
Without today, you don't know what to improve tomorrow.
UTNGY Pisal
Uncomplicated cryptography frameworks base on CommonCrypto

Keys - Keys of data encryption 中文介绍 Example let password = Password("Secret") let key = SymmetricKey() password.encrypt(data) let data = "Hello Wo

Xingzhi Zheng 47 Jun 12, 2022
A swift libray to calculate file hash.

FileHash A swift libray to calculate file hash. Usage let path = "file_path_string" let md5 = Hasher.md5HashOfFile(atPath: path) let sha1

C-凡 4 Sep 11, 2022
Squirrel3 - Squirrel3 hash/noise function from Squirrel Eiserloh

Squirrel3 A Swift implementation of the Squirrel3 hash function and pseudo-rando

Joseph Heck 2 Jan 2, 2022
CCCryptor (AES encryption) wrappers for iOS and Mac in Swift. -- For ObjC, see RNCryptor/RNCryptor-objc

RNCryptor Cross-language AES Encryptor/Decryptor data format. The primary targets are Swift and Objective-C, but implementations are available in C, C

null 3.3k Dec 30, 2022
RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

Kitura 122 Dec 16, 2022
RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

Kitura 122 Dec 16, 2022
RSA encrypt and decrypt in Swift

MZRSA_Swift MZRSA_Swift是一个轻量级框架,框架功能包含RSA加密/解密Data、RSA加密/解密String,支持字符串密钥和证书密钥 公钥加密&私钥解密(字符串密钥) 代码示例 let PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8

null 8 Jan 5, 2023
Swift RSA Key Loader

Swift RSA Key Loader Requirements iOS 9.0+ Installation See the subsections below for details about the different installation methods. Swift Package

Dmytrii Golovanov 1 Jun 13, 2022
A customizable verification code textField. Can be used for phone verification codes, passwords etc

KKPinCodeTextField A customizable verification code textField. Can be used for phone verification codes, passwords etc. Настраиваемое текстовое поле д

Kolesa Group 66 Jul 5, 2022
Simple and secure hashing in Swift with the SipHash algorithm

SipHash ⚠️ WARNING This package has been obsoleted by the Hasher type and the Hashable.hash(into:) requirement introduced in Swift 4.2. Using this pac

null 262 Dec 19, 2022