Latest 1.0.8
Homepage https://github.com/daisuke-t-jp/FNV
License MIT
Platforms ios 10.0, osx 10.12, tvos 12.0, requires ARC
Authors

FNV

Platform
Language Swift%204.2
Cocoapods
Carthage compatible
SwiftPM compatible
Build Status

Introduction

FNV (Fowler/Noll/Vo) hash framework in Swift.
A framework includes 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 :

Requirements

  • Platforms
    • iOS 10.0+
    • macOS 10.12+
    • tvOS 12.0+
    • Linux
  • Swift 4.2+

Installation

CocoaPods

use_frameworks!

target 'target' do
pod 'FNV'
end

Carthage

github "daisuke-t-jp/FNV"

Swift Package Manager

import PackageDescription

let package = Package(
    name: "YOUR_PACKAGE_NAME",
    targets: [],
    dependencies: [
        .package(url: "https://github.com/daisuke-t-jp/FNV.git", from: "1.0.0")
    ]
    targets: [
        .target(
            name: "YOUR_TARGET_NAME",
            dependencies: ["FNV"]),
    ]
)

Usage

Import framework

import FNV

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)!)

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)!)

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)!)

Latest podspec

{
    "name": "FNV",
    "version": "1.0.8",
    "summary": "FNV hash framework in Swift.",
    "description": "This is "FNV" (Fowler/Noll/Vo) hash framework in Swift.nA framework includes "FNV-0 32/64bit", "FNV-1 32/64bit", "FNV-1a 32/64bit" functions.nnOriginal FNV algorithm created by Glenn Fowler, Landon Curt Noll, and Kiem-Phong Vo.",
    "homepage": "https://github.com/daisuke-t-jp/FNV",
    "screenshots": "https://raw.githubusercontent.com/daisuke-t-jp/FNV/master/doc/header.png",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "daisuke-t-jp": "[email protected]"
    },
    "platforms": {
        "ios": "10.0",
        "osx": "10.12",
        "tvos": "12.0"
    },
    "source": {
        "git": "https://github.com/daisuke-t-jp/FNV.git",
        "tag": "1.0.8"
    },
    "source_files": "Sources/FNV/*.{swift}",
    "swift_version": "4.2",
    "requires_arc": true
}

Pin It on Pinterest

Share This