Encryption lib (CryptoKit wrapper)
Cipher is an encryption library that serves as a wrapper for CryptoKit. It provides functionalities such as generating key pairs, creating shared keys for end-to-end encryption, and encrypting and decrypting data using a password key.
Cipher provides a comprehensive set of cryptographic operations, including:
- Key Generation: Generate symmetric keys for encryption and decryption.
- Encryption and Decryption: Encrypt and decrypt data using symmetric keys.
- Key Export and Import: Export and import keys to and from raw string representations.
- Shared Key Creation: Create shared keys for end-to-end encryption using the Diffie-Hellman key agreement.
- Password-based Encryption: Encrypt and decrypt data using a password key.
This example demonstrates how to use the Cipher library to generate a key pair, create a shared key for end-to-end encryption, and encrypt and decrypt data using a password key.
// Keys
let keypair: KeyPair = try Cipher.keyPair() // priv / pub key
let sharedKey : SymetricKey = Cipher.sharedKey(privKey:.., pubKey:..) // used for E2EE
let privKey: SymmetricKey = Cipher.privKey // private key
// Encrypt data
let pswKey: SymmetricKey = try Cipher.passwordKey(password: "abc123")
let encryptedData: Data = try Cipher.encrypt(data: "hello world".data(using: .utf8)!, key: pswKey) // Decrypt payload with local shared key
let decryptedData: Data = try Cipher.decrypt(data: encryptedData, key: pswKey) // Decrypt payload with remote shared key
String(data: decryptedData, encoding: .utf8) // abc123
Topic | Link |
---|---|
Diffie hellman | Link |
CryptoKit | Link |
xchacha20 | Link |
Encrypting data with CryptoKit and custom password | Link |
Common cryptographic operations in Swift with CryptoKit | Link |
Library | Link |
---|---|
Argon2id | Link |
Blake2b | Link |
XChaCha20 | Link |
Poly1305 | Link |
swift-sodium | Link |
- Add more / better doc and examples
- Show how migration API would work etc
- Color decorate different chars in passwords, letter gets one color, number another, symbol another. see: https://github.com/keepassium/KeePassium/blob/master/KeePassium/util/PasswordStringHelper.swift
- Add some more doc around salt
- Add Introduction: Expand the introduction to include more details about the library. What makes it unique? Why should someone use it over other libraries? What problems does it solve? Installation: Include a section on how to install and setup your library. This could include the commands to run, any dependencies that need to be installed, etc.
- Add Usage: Expand the examples section to include more comprehensive examples. Show how to use the library in a real-world scenario. This could include examples of how to handle errors, how to use the library in a larger project, etc.
- Clean up this readme. esp the tables