Home

Awesome

Hash

CI Status Version Carthage compatible Maintainability License Platform Swift 5.0 Reviewed by Hound

Hash provides a convenient means of converting a message in Swift Data or String format to a message digest (hashing) or generating a HMAC using one of the following hash functions: MD2 MD4, MD5, SHA-1, SHA224, SHA-256, SHA-384 or SHA-512. Also supported are encryption and decryption using AES-128, AES-192 or AES-256.

Features

Installation

Cocoapods

CocoaPods is a dependency manager which integrates dependencies into your Xcode workspace. To install it using Ruby gems run:

gem install cocoapods

To install Hash using Cocoapods, simply add the following line to your Podfile:

pod "Hash"

Then run the command:

pod install

For more information see here.

Carthage

Carthage is a dependency manager which produces a binary for manual integration into your project. It can be installed via Homebrew using the commands:

brew update
brew install carthage

In order to integrate Hash into your project via Carthage, add the following line to your project's Cartfile:

github "rwbutler/Hash"

From the macOS Terminal run carthage update --platform iOS to build the framework then drag Hash.framework into your Xcode project.

For more information see here.

Swift Package Manager

The Swift Package Manager is a dependency manager for Swift modules and is included as part of the build system as of Swift 3.0. It is used to automate the download, compilation and linking of dependencies.

To include Hash as a dependency within a Swift package, add the package to the dependencies entry in your Package.swift file as follows:

dependencies: [
    .package(url: "https://github.com/rwbutler/Hash.git", from: "1.0.0")
]

Usage

For an example of how to use Hash, see the sample app in the Example directory.

Message Digests (Hashing)

if let hash = Hash(message: "Hello World!", algorithm: .sha256) {
    print(hash)
}

Prints:

7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069

HMACs

if let hash = HMAC(message: "Hello World!", key: "123", algorithm: .sha1) {
    print(hash)
}

Prints:

‌5471001127ed5f6261576c66033d9cbe37c7c91e

Encryption

Currently supported encryption algorithms are: AES-128, AES-192 and AES-256.

if let cipherText = CipherText(message: "Hello World!", key: "01234567890123450123456789012345", iv: "0123456789012345", algorithm: .aes256) {
    print(cipherText)
}

Prints:

‌6a790fe6c15590a6434d3ee3a866d327

Decryption

Currently supported decryption algorithms are: AES-128, AES-192 and AES-256.

if let cipherText = Data(hex: "6a790fe6c15590a6434d3ee3a866d327"),
	let keyData = "01234567890123450123456789012345".data(using: .utf8) {
    let plainText = PlainText(message: message, key: keyData, iv: "0123456789012345".data(using: .utf8), algorithm: .aes256)
    print(plainText)
}

Prints:

‌Hello World!

Author

Ross Butler

License

Hash is available under the MIT license. See the LICENSE file for more info.

Additional Software

Controls

AnimatedGradientView
AnimatedGradientView

Frameworks

CheatsConnectivityFeatureFlagsSkylarkTypographyKitUpdates
CheatsConnectivityFeatureFlagsSkylarkTypographyKitUpdates

Tools

Config ValidatorIPA UploaderPalette
Config ValidatorIPA UploaderPalette