Giter Site home page Giter Site logo

humanhash's Introduction

humanhash

Groovy implementation of human readable hashes, compatible with https://github.com/zacharyvoase/humanhash ie. it uses an identical word list and hash 'translation' function.

Example usage

import com.whartonlabs.humanhash.HumanHasher

String digest = "7528880a986c40e78c38115e640da2a1"

/*
  Pass in a digest that contains only hexidecimal characters (0-9 and a-f), 
  and get back a human readable translation that's 4 words long, each word from a dictionary of 256 words.
  Using 4 words, there are 2^32 possible hashes, or ~ 4.3 billion
 */
assert new HumanHasher().humanize(digest) == "three-georgia-xray-jig"

/* 
  You can change the fidelity of the humanized hash by requesting a different number of words, 
  giving the number as a second argument
 */
assert new HumanHasher().humanize(digest, 6) == "high-mango-white-oregon-purple-charlie"

/*
  You can also pass in your own custom word list to the constructor, 
  useful for improving recognition for usage with languages other than english.
 */
def customWordList = (0..255).collect { "alfa" } // not a useful wordlist, but demonstrates the point...
assert new HumanHasher(customWordList).humanize(digest) == "alfa-alfa-alfa-alfa"

That's really all there is to it!

Running the tests

Comes with Gradle wrapper, so nothing to install. Just navigate to the repository's root directory (where the build.gradle file is) and run

./gradlew test

Maven

Currently available from the OSS Sonatype repository at https://oss.sonatype.org/content/repositories/snapshots

Your Gradle dependency would be

compile 'com.whartonlabs:humanhash:0.2-SNAPSHOT'

License

Licensed under the terms of the Unlicense.

humanhash's People

Contributors

andrew-wharton avatar

Stargazers

Brandon Silver avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.