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

MurmurHash-Swift

Platform
Language Swift%204.2
Carthage compatible
Cocoapods
Build Status

Introduction

MurmurHash framework in Swift.
Framework include x86_32, x86_128, x64_128 functions.

Reference :

Install

Carthage

github "daisuke-t-jp/MurmurHash-Swift"

CocoaPods

use_frameworks!

target 'target' do
pod 'MurmurHash-Swift'
end

Usage

Import framework

import MurmurHash_Swift

Generate x86/32bit Hash

/**
 * Generate.
 */
// Generate hash from String.
let hash = MurmurHash3.x86_32("Hello World!")
print(String.init(format: "0x%x", hash)) // "0xdc09357d"

// Generate hash from [UInt8].
let hash = MurmurHash3.x86_32(Array("Hello World!".utf8))

// Generate hash from Data.
let hash = MurmurHash3.x86_32("Hello World!".data(using: .utf8)!)

/**
 * Using seed.
 */
let seed = 0x7fffffff

// Generate hash from String.
let hash = MurmurHash3.x86_32("Hello World!", seed: seed)
print(String.init(format: "0x%x", hash)) // "0xf98a8b8e"

// Generate hash from [UInt8].
let hash = MurmurHash3.x86_32(Array("Hello World!".utf8), seed: seed)

// Generate hash from Data.
let hash = MurmurHash3.x86_32("Hello World!".data(using: .utf8)!, seed: seed)

Generate x86/128bit Hash

/**
 * Generate.
 */
// Generate hash from String.
let hash = MurmurHash3.x86_128("Hello World!")
print(String.init(format: "0x%x%x%x%x", hash.h1, hash.h2, hash.h3, hash.h4)) // "0x6bee9883eb1be4f59dfb7172ae3fbea9"

// Generate hash from [UInt8].
let hash = MurmurHash3.x86_128(Array("Hello World!".utf8))

// Generate hash from Data.
let hash = MurmurHash3.x86_128("Hello World!".data(using: .utf8)!)

/**
 * Using seed.
 */
let seed = 0x7fffffff

// Generate hash from String.
let hash = MurmurHash3.x86_128("Hello World!", seed: seed)
print(String.init(format: "0x%x%x%x%x", hash.h1, hash.h2, hash.h3, hash.h4)) // "0xa8c348436bb9375369e62d2b2cefbb56"

// Generate hash from [UInt8].
let hash = MurmurHash3.x86_128(Array("Hello World!".utf8), seed: seed)

// Generate hash from Data.
let hash = MurmurHash3.x86_128("Hello World!".data(using: .utf8)!, seed: seed)

Generate x64/128bit Hash

/**
 * Generate.
 */
// Generate hash from String.
let hash = MurmurHash3.x64_128("Hello World!")
print(String.init(format: "0x%lx%lx", hash.h1, hash.h2)) // "0x80025454af3196b2e57813856f452fa6"

// Generate hash from [UInt8].
let hash = MurmurHash3.x64_128(Array("Hello World!".utf8))

// Generate hash from Data.
let hash = MurmurHash3.x64_128("Hello World!".data(using: .utf8)!)

/**
 * Using seed.
 */
let seed = 0x7fffffff

// Generate hash from String.
let hash = MurmurHash3.x64_128("Hello World!", seed: seed)
print(String.init(format: "0x%lx%lx", hash.h1, hash.h2)) // "0xa8c348436bb9375369e62d2b2cefbb56"

// Generate hash from [UInt8].
let hash = MurmurHash3.x64_128(Array("Hello World!".utf8), seed: seed)

// Generate hash from Data.
let hash = MurmurHash3.x64_128("Hello World!".data(using: .utf8)!, seed: seed)

Latest podspec

{
    "name": "MurmurHash-Swift",
    "version": "1.0.7",
    "summary": "MurmurHash framework in Swift.",
    "description": ""MurmurHash" framework in Swift.nFramework include "MurmurHash3 x86_32, x86_128, x64_128" functions.",
    "homepage": "https://github.com/daisuke-t-jp/MurmurHash-Swift",
    "screenshots": "https://raw.githubusercontent.com/daisuke-t-jp/MurmurHash-Swift/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/MurmurHash-Swift.git",
        "tag": "1.0.7"
    },
    "source_files": "MurmurHash/MurmurHash/*.{h,swift}",
    "swift_version": "4.2",
    "requires_arc": true
}

Pin It on Pinterest

Share This