checksum

package
v0.0.0-...-fae07df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2016 License: MIT, MIT Imports: 11 Imported by: 0

README

Checksum

Create checksums with ease

##Installation Download and install go-checksum with go get

go get github.com/rauwekost/go-checksum

##Usage

package main

import (
  "crypto"
  "fmt"

  "github.com/rauwekost/go-checksum"
)

func main() {
  //md5 of a string
  c, err := checksum.String("password", crypto.MD5)
  if err != nil {
    panic(err)
  }
  fmt.Printf("MD5 = %s\n", c)

  //sha1 of a string
  c, err = checksum.String("password", crypto.SHA1)
  if err != nil {
    panic(err)
  }
  fmt.Printf("SHA1 = %s\n", c)

  //sha256 of a file
  c, err = checksum.File("testfile.txt", crypto.SHA256)
  if err != nil {
    panic(err)
  }
  fmt.Printf("SHA256 = %s\n", c)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(b []byte, method crypto.Hash) (string, error)

Bytes return a hash for the given bytes

func File

func File(path string, method crypto.Hash) (string, error)

File returns a hash for the given file

func String

func String(s string, method crypto.Hash) (string, error)

String returns a hash for the given string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL