Coder Social home page Coder Social logo

muhasturk / bmhcrypto Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 20 KB

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

License: MIT License

Swift 100.00%
crypto cryptography encryption decryption algorithms swift swift-package-manager xcode cryptokit extensions

bmhcrypto's Introduction

BMHCrypto


BMHCrypto

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

Why?

Simplify usage of cryptographic operation such as hashing, encryption / decryption. Pure Swift, I am not gonna reinvent the wheel, package always will be based on CryptoKit or whatever released by Apple.

๐Ÿ“‹ Requirements

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

๐Ÿ“ฒ Installation

Swift Package Manager

Xcode Project

Swift Package Manager 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

You can use The Swift Package Manager to install BMHCrypto by adding the proper description to your Package.swift file:

import PackageDescription

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

Next, add BMHCrypto to your targets dependencies like so:

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

Then run swift package update.

๐ŸŽ Features

  • Insecure Hash

    • MD5
    • 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

    • SHA256
    • SHA384
    • SHA512
  • Ciphers

    • AES
    • ChaChaPoly
  • Message Authentication Codes

    • HMAC
    • 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.

bmhcrypto's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

00mjk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.