Contents

muhasturk/bmhcrypto

BMHCrypto is a pure Swift packages built on CryptoKit, adds useful extensions and ready to use.

๐Ÿ“‹ Requirements

  • iOS 13.0+ / tvOS 13.0+ / watchOS 6.0+ / macOS 10.15+
  • Swift 5.0+

๐Ÿ“ฒ Installation

<details> <summary>Swift Package Manager</summary> </br>

Xcode Project

<a href="https://swift.org/package-manager">Swift Package Manager</a> is built into new versions of Xcode. To install BMHCrypto with SPM:

  • Open your project in Xcode
  • Click "File" -> "Swift Packages" -> "Add Package Dependency..."
  • Paste the following URL:

https://github.com/muhasturk/BMHCrypto.git

  • Click "Next" -> "Next" -> "Finish"
As Dependecy

<p>You can use <a href="https://swift.org/package-manager">The Swift Package Manager</a> to install <code>BMHCrypto</code> by adding the proper description to your <code>Package.swift</code> file:</p>

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .package(url: "https://github.com/muhasturk/BMHCrypto.git", from: "0.1.0")
    ]
)

<p>Next, add <code>BMHCrypto</code> to your targets dependencies like so:</p>

.target(
    name: "YOUR_TARGET_NAME",
    dependencies: [
        "BMHCrypto",
    ]
),

<p>Then run <code>swift package update</code>.</p> </details>

๐ŸŽ Features

  • Insecure Hash

- [x] MD5 - [x] SHA1 > Important: These algorithms arenโ€™t considered cryptographically secure, but are provided for backward compatibility with older services that require them. For new services, avoid these algorithms.

  • Cryptographically Secure Hashes

- [x] SHA256 - [x] SHA384 - [x] SHA512

  • Ciphers

- [x] AES - [x] ChaChaPoly

  • Message Authentication Codes

- [ ] HMAC - [x] SymmetricKey

  • [ ] Public-Key Cryptography

๐Ÿ”ฅ Usage

Do not forget to import

import BMHCrypto

Hashing

// Anything That Conforms DataProtocol
let plainText = "BMH"
// Returns String Representation
plainText.md5
plainText.sha1
plainText.sha256
plainText.sha384
plainText.sha512

Ciphers

  • ChaChaPoly
// Share Same Key
let key = SymmetricKey(size: .bits256) 

// Plain Data Could Be Anything
let data = Data()

// Encrypt
let encrypted = data.encryptChaChaPoly(with: key)

// Decrypt
let decrypted = encrypted.decryptChaChaPoly(with: key)
  • AES
// Share Same Key
let key = SymmetricKey(size: .bits256) 

// Plain Data Could Be Anything
let data = Data()

// Encrypt
let encrypted = data.encryptAES(with: key)

// Decrypt
let decrypted = encrypted?.decryptAES(with: key)

Sharing Key

let key = SymmetricKey(size: .bits256) 

// Shareable String Key
let savedKey = key.base64EncodedString

// Ready to Use SymmetricKey
let convertedKey = savedKey.asSymmetricKey

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Author

Mustafa Hasturk ๐Ÿ“ง mustafa[at]hasturk.dev

โค๏ธ Contributing

Bug reports and pull requests are welcome.

๐Ÿ‘ฎ๐Ÿปโ€โ™‚๏ธ License

BMHCrypto is released under the MIT license. See LICENSE for more information.

Package Metadata

Repository: muhasturk/bmhcrypto

Default branch: master

README: README.md