FNV

FNV hash framework in Swift.


Keywords
carthage, cocoapods, fnv, hash, ios, macos, swift, tvos
License
MIT
Install
pod try FNV

Documentation


Platform Language Swift%204.2 Carthage compatible Cocoapods Build Status

What is this?

FNV (Fowler/Noll/Vo) hash framework in Swift.
Framework include FNV-0 32/64bit, FNV-1 32/64bit, FNV-1a 32/64bit functions.

Original FNV algorithm created by Glenn Fowler, Landon Curt Noll, and Kiem-Phong Vo.

Reference :

Install

Carthage

github "daisuke-t-jp/FNV"

CocoaPods

use_frameworks!

target 'target' do
pod 'FNV'
end

Usage

import FNV



// MARK: - FNV-0
/**
 * 32bit hash
 */
// Generate from [UInt8].
let hash = FNV.fnv0_32(Array("string".utf8))

// Generate from String.
let hash = FNV.fnv0_32("string")

// Generate from Data.
let hash = FNV.fnv0_32("string".data(using: .utf8)!)


/**
 * 64bit hash
 */
// Generate from [UInt8].
let hash = FNV.fnv0_64(Array("string".utf8))

// Generate from String.
let hash = FNV.fnv0_64("string")

// Generate from Data.
let hash = FNV.fnv0_64("string".data(using: .utf8)!)



// MARK: - FNV-1
/**
 * 32bit hash
 */
// Generate from [UInt8].
let hash = FNV.fnv1_32(Array("string".utf8))

// Generate from String.
let hash = FNV.fnv1_32("string")

// Generate from Data.
let hash = FNV.fnv1_32("string".data(using: .utf8)!)


/**
 * 64bit hash
 */
// Generate from [UInt8].
let hash = FNV.fnv1_64(Array("string".utf8))

// Generate from String.
let hash = FNV.fnv1_64("string")

// Generate from Data.
let hash = FNV.fnv1_64("string".data(using: .utf8)!)
                


// MARK: - FNV-1a
/**
 * 32bit hash
 */
// Generate from [UInt8].
let hash = FNV.fnv1a_32(Array("string".utf8))

// Generate from String.
let hash = FNV.fnv1a_32("string")

// Generate from Data.
let hash = FNV.fnv1a_32("string".data(using: .utf8)!)


/**
 * 64bit hash
 */
// Generate from [UInt8].
let hash = FNV.fnv1a_64(Array("string".utf8))

// Generate from String.
let hash = FNV.fnv1a_64("string")

// Generate from Data.
let hash = FNV.fnv1a_64("string".data(using: .utf8)!)