Hash

master

🔐Lightweight generation of message digests & HMACs with support for popular cryptographic algorithms.
rwbutler/Hash

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

  • Lightweight and easy to use interface.
  • Support for hashing using the following popular algorithms: MD2 MD4, MD5, SHA-1, SHA224, SHA-256, SHA-384 or SHA-512.
  • Support for generating HMACs using the following popular algorithms: MD5, SHA-1, SHA224, SHA-256, SHA-384 or SHA-512.
  • Support for encryption & decryption using AES-128, AES-192 or AES-256.
  • Compatible with iOS 8.0 and above.

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

  • Cheats - Retro cheat codes for modern iOS apps.
  • Connectivity - Improves on Reachability for determining Internet connectivity in your iOS application.
  • FeatureFlags - Allows developers to configure feature flags, run multiple A/B or MVT tests using a bundled / remotely-hosted JSON configuration file.
  • FlexibleRowHeightGridLayout - A UICollectionView grid layout designed to support Dynamic Type by allowing the height of each row to size to fit content.
  • Hash - Lightweight means of generating message digests and HMACs using popular hash functions including MD5, SHA-1, SHA-256.
  • Skylark - Fully Swift BDD testing framework for writing Cucumber scenarios using Gherkin syntax.
  • TailorSwift - A collection of useful Swift Core Library / Foundation framework extensions.
  • TypographyKit - Consistent & accessible visual styling on iOS with Dynamic Type support.
  • Updates - Automatically detects app updates and gently prompts users to update.
Cheats Connectivity FeatureFlags Skylark TypographyKit Updates
Cheats Connectivity FeatureFlags Skylark TypographyKit Updates

Tools

  • Clear DerivedData - Utility to quickly clear your DerivedData directory simply by typing cdd from the Terminal.
  • Config Validator - Config Validator validates & uploads your configuration files and cache clears your CDN as part of your CI process.
  • IPA Uploader - Uploads your apps to TestFlight & App Store.
  • Palette - Makes your TypographyKit color palette available in Xcode Interface Builder.
Config Validator IPA Uploader Palette
Config Validator IPA Uploader Palette

Description

  • Swift Tools 4.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Mar 16 2024 12:53:48 GMT-0900 (Hawaii-Aleutian Daylight Time)