lovetodream / swift-blake2

Pure Swift implementation of the BLAKE2 hash function based on RFC7693 without sacrificing performance

Home Page:https://swiftpackageindex.com/lovetodream/swift-blake2/main/documentation/blake2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swift-blake2

A pure Swift implementation of BLAKE2.

RFC 7693: The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)

If you don't want to add yet another dependency to your project, you can copy the file BLAKE2b.swift (Do not remove the license header!).

Usage

You can compute digest in a single step using the static hash(data:key:digestLength:salt:) method.

let digest = try BLAKE2b.hash(data: "hello, world!".data(using: .utf8)!)

If you want to compute the digest of a large amount of data, you can initialize an instance of BLAKE2b and call update(data:) as often as you need to. To finalize and return the digest, call finalize().

var hasher = try BLAKE2b()
hasher.update(data: "hello, ".data(using: .utf8)!)
hasher.update(data: "world!".data(using: .utf8)!)
let digest = hasher.finalize()

About

Pure Swift implementation of the BLAKE2 hash function based on RFC7693 without sacrificing performance

https://swiftpackageindex.com/lovetodream/swift-blake2/main/documentation/blake2

License:Apache License 2.0


Languages

Language:Swift 100.0%