Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/muhasturk/bmhcrypto
BMHCrypto is a pure Swift packages built on CryptoKit, adds useful extensions and ready to use.
https://github.com/muhasturk/bmhcrypto
aes-encryption algorithms chipher crypto cryptography cryptokit decryption encryption extensions hashing swift swift-package-manager symmetric-key-cryptography xcode
Last synced: about 14 hours ago
JSON representation
BMHCrypto is a pure Swift packages built on CryptoKit, adds useful extensions and ready to use.
- Host: GitHub
- URL: https://github.com/muhasturk/bmhcrypto
- Owner: muhasturk
- License: mit
- Created: 2020-04-25T03:09:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-10T19:22:16.000Z (over 2 years ago)
- Last Synced: 2024-10-28T18:01:08.508Z (18 days ago)
- Topics: aes-encryption, algorithms, chipher, crypto, cryptography, cryptokit, decryption, encryption, extensions, hashing, swift, swift-package-manager, symmetric-key-cryptography, xcode
- Language: Swift
- Size: 19.5 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 yourPackage.swift
file:```swift
import PackageDescriptionlet 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:```swift
.target(
name: "YOUR_TARGET_NAME",
dependencies: [
"BMHCrypto",
]
),
```Then run
swift package update
.## ๐ 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
```swift
import BMHCrypto
```
### Hashing```swift
// Anything That Conforms DataProtocol
let plainText = "BMH"
``````swift
// Returns String Representation
plainText.md5
plainText.sha1
plainText.sha256
plainText.sha384
plainText.sha512
```### Ciphers
- ChaChaPoly
```swift
// 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
```swift
// 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
```swift
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](https://github.com/muhasturk/BMHCrypto/blob/master/LICENSE) for more information.