Giter Club home page Giter Club logo

blockhash-go's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dsoprea

blockhash-go's Issues

Inaccuracy

It seems like something is off in the algorithm. The hash is sometimes correct, but not always.

Test code:

package main

import (
    "os"
    "fmt"

    "github.com/jessevdk/go-flags"

    "github.com/haochi/blockhash-go"
    "github.com/dsoprea/go-logging"
)

type options struct {
    Filepath string `short:"f" long:"filepath" required:"true" description:"File-path of image"`
}

func main() {
    o := new(options)
    if _, err := flags.Parse(o); err != nil {
        os.Exit(1)
    }

    f, err := os.Open(o.Filepath)
    log.PanicIf(err)

    defer f.Close()

    h, err := blockhash.Blockhash(f, 16)
    log.PanicIf(err)

    digest := h.ToHex()
    fmt.Println(digest)
}

Using the Blockbash Python tool with four images (two valley scenes and two sizes of each, where one is full-sized and the other is scaled to 100-pixels wide):

$ python blockhash.py ~/Downloads/*jpg
1ffc3fff00fe000021ff7e3f0f8007c03fff1f8d0f9806003ffc3ff80f0400f0  /home/dustin/Downloads/20170618_155330.jpg
1ffc3fff00fe000031ff3e3f0f8007c03fff1f8d0f9806003ffc3ff80f0400f0  /home/dustin/Downloads/20170618_155330-small.jpg
7ff00fe00ff007e00ffd07f807f003f003fc07fa07f413f017f927e261cce0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers.jpg
7ff00fe00fe007f00ffd07f807f003f003fc07fa07f413f013f92fe261cce0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers-small.jpg

If I run the Go tool, I'l get:

$ go run blockhash-go-testing.go -f ~/Downloads/20170618_155330.jpg 
1ffc3fff007e000021ff3e3f0f8007c03fff1f8c0f9806003ffc3ff80f0000f0
$ go run blockhash-go-testing.go -f ~/Downloads/20170618_155330-small.jpg 
1ffc1fff007f000013ff3c3f0f8007c03ffa1f8e0f840e083ffc1ffc0fc00300
$ go run blockhash-go-testing.go -f ~/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers.jpg 
7ff00fe00fe007e00ffd07f807f003e003fc03fa07f413f013f92fe261c4e0d8
$ go run blockhash-go-testing.go -f ~/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers-small.jpg 
7ff00fe00fe007e007fc07f807f803f003fe03fe03f803f007fa1bf811f405e1

Notice that the full-size images have the same hashes as the Python tool, but the shrunk versions have a hash with a common-prefix (the first few characters are correct; the first seventeen characters in the first case and the first ten-characters in the other case) though the not all of the bytes match.

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.