All Projects → rnine → Checksum

rnine / Checksum

Licence: MIT License
Checksum calculation extensions for Swift

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to Checksum

hediye
Hash Generator & Cracker
Stars: ✭ 40 (+42.86%)
Mutual labels:  md5, sha1, sha256, sha512, sha384, sha224
hash-checker
Fast and simple application that allows you to generate and compare hashes from files and text
Stars: ✭ 72 (+157.14%)
Mutual labels:  md5, sha1, sha256, sha512, sha384, sha224
WebCrypto.swift
A small collection of cryptographic functions based on the JavaScript WebCrypto API.
Stars: ✭ 16 (-42.86%)
Mutual labels:  digest, sha1, sha256, sha512, sha384
Gtkhash
A cross-platform desktop utility for computing message digests or checksums
Stars: ✭ 167 (+496.43%)
Mutual labels:  checksum, md5, sha1, sha256
fhash
fHash - an open source files hash calculator for Windows and macOS
Stars: ✭ 222 (+692.86%)
Mutual labels:  md5, sha1, sha256, sha512
hash-wasm
Lightning fast hash functions using hand-tuned WebAssembly binaries
Stars: ✭ 382 (+1264.29%)
Mutual labels:  md5, sha1, sha256, sha512
Openhashtab
📝 File hashing and checking shell extension
Stars: ✭ 599 (+2039.29%)
Mutual labels:  checksum, md5, sha1, sha256
Gensum
Powerful checksum generator!
Stars: ✭ 12 (-57.14%)
Mutual labels:  checksum, md5, sha1, sha256
BruteForce
A simple brute forcer written in GO for SHA1, SHA256, SHA512, MD5 and bcrypt
Stars: ✭ 49 (+75%)
Mutual labels:  md5, sha1, sha256
Hashcobra
HashCobra Hash Cracking tool.
Stars: ✭ 96 (+242.86%)
Mutual labels:  md5, sha1, sha256
crypto.js
base on crypto module
Stars: ✭ 13 (-53.57%)
Mutual labels:  md5, sha1, sha256
Blooddy crypto
ActionScript (AS3) library for processing binary data. This library contains MD5, SHA-1, SHA-2 ( SHA-224 и SHA-256 ), Base64, CRC32 algorithms, JSON encoder & decoder as well as PNG and JPEG encoders.
Stars: ✭ 83 (+196.43%)
Mutual labels:  md5, sha1, sha256
Wjcryptlib
Public Domain C Library of Cryptographic functions. Including: MD5, SHA1, SHA256, SHA512, RC4, AES, AES-CTR, AES-OFB, AES-CBC
Stars: ✭ 250 (+792.86%)
Mutual labels:  md5, sha1, sha256
Pure lua sha
SHA1, SHA2 and SHA3 functions written in pure Lua and optimized for speed
Stars: ✭ 78 (+178.57%)
Mutual labels:  md5, sha1, sha256
Digestif
Simple hash algorithms in OCaml
Stars: ✭ 69 (+146.43%)
Mutual labels:  md5, sha1, sha256
Hash Library
Portable C++ hashing library
Stars: ✭ 109 (+289.29%)
Mutual labels:  md5, sha1, sha256
Hashrat
Hashing tool supporting md5,sha1,sha256,sha512,whirlpool,jh and hmac versions of these. Includes recursive file hashing and other features.
Stars: ✭ 46 (+64.29%)
Mutual labels:  md5, sha1, sha256
Crypto Es
A cryptography algorithms library
Stars: ✭ 65 (+132.14%)
Mutual labels:  md5, sha1, sha256
Cryptoswift
CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift
Stars: ✭ 8,846 (+31492.86%)
Mutual labels:  md5, digest, sha1
Merkle
Node.js module implementing Merkle tree algorithm
Stars: ✭ 123 (+339.29%)
Mutual labels:  md5, sha1, sha256

Checksum

Platform Swift support Carthage compatible Swift Package Manager compatible

GitHub tag License

Extends String, Data, and URL adding the ability to easily and efficiently calculate the cryptographic checksum of its associated contents by adding conformance to the Checksumable protocol.

Under the hood, Apple's CommonCrypto framework is used.

Requirements

  • iOS 9 / macOS 10.11 / tvOS 9 / watchOS 2
  • Xcode 10.2
  • Swift 4.0 / 4.2 / 5.0 / 5.1

Documentation

Features

Supported Digests

MD5, SHA1, SHA224, SHA256, SHA384, SHA512

Async Processing

Processing and progress monitoring are performed asynchronously on a background dispatch queue. Progress and completion closures are, by default, called on the .main dispatch queue. However, a different DispatchQueue may be specified.

The function signature for async processing is:

  • checksum(algorithm:chunkSize:queue:progress:completion:)

Sync Processing

In the cases where the payload is fairly small, asynchronous processing may not be required or desirable. For such cases, a synchronous version is provided.

The function signature for sync processing is:

  • checksum(algorithm:chunkSize:)

Process Local or Remote URLs

Any URLs with schemes file, http, or https may be used as input. However, http and https support is currently experimental and has the following requirements:

  1. The HTTP server must be able to respond to HEAD requests in order to determine whether the URL is reachable.
  2. The HTTP server must be able to serve 206 Partial Content responses.

Batch Processing

Support for processing arrays of Checksumable items is also included and showcased in the examples below.

Examples

Calculating the checksum of some Data asynchronously

data.checksum(algorithm: .md5) { result in
    switch result {
    case .success(let checksum):
        // Use checksum
    case .failure(let error):
        // Unable to obtain checksum
    }
}

Calculating the checksum of the content at a given URL asynchronously

remoteURL.checksum(algorithm: .sha256) { result in
    switch result {
    case .success(let checksum):
        // Use checksum
    case .failure(let error):
        // Unable to obtain checksum
    }
}

Calculating the checksums of the contents at given URLs asynchronously

[someURL, anotherURL, yetAnotherURL].checksum(algorithm: .md5) { result in
    switch result {
    case .success(let checksumResults):
        // Use results object
        
        for checksumResult in checksumResults {
            guard let url = checksumResult.checksumable as? URL else {
                fail("Expected checksumable to be of type URL.")
                return
            }
            
            if let checksum = checksumResult.checksum {
                print("Checksum of \(result.checksumable) is \(checksumResult.checksum)")
            } else {
                print("Unable to obtain checksum for \(checksumResult.checksumable)")
            }
        }
    case .failure(let error):
        // Unable to obtain checksums
    }
}

Calculating the checksum of some String synchronously

if let checksum = string.checksum(algorithm: .md5) {
    // Use checksum
}

Calculating the checksum of some Data synchronously

if let checksum = data.checksum(algorithm: .md5) {
    // Use checksum
}

Calculating the checksum of the content at a given URL synchronously

if let checksum = localURL.checksum(algorithm: .md5) {
    // Use checksum
}

Progress Reporting

You may monitor progress by passing a ProgressHandler closure to the progress argument in checksum(algorithm:chunkSize:queue:progress:completion:).

Example

remoteURL.checksum(algorithm: .sha256, progress: { progress in
    // Add your progress handling code here.
    print("Fraction completed: \(progress.fractionCompleted)")
}) { result in 
    /// Result handling ommited.
}

License

Checksum was written by Ruben Nine (@sonicbee9) and is licensed under the MIT license. See LICENSE.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].