Coder Social home page Coder Social logo

salty64's Introduction

Salty64

This is a Go package that is used to generate a hash of a string with a minimum level of security. The ideal scenario is if you need to generate an ID for a record that is based on one or more fields combined together and will be the same every time it is generated. This is not meant to be a secure string or used for passwords in any way, simply as a hash to identify a record in a way that does not leak anything like an email address or name in plain text. There are reversible and non-reversible methods.

Installation

go get -u github.com/bit-cmdr/salty64

Testing

go test .

Benchmarking

go test -bench=. -benchmem

Example

package main

import (
	"github.com/bit-cmdr/salty64"
    "fmt"
    "os"
)

func main() {
    email := "[email protected]"

    s, err := salty64.NewShaker("secret", 2)
    if err != nil {
        fmt.Printf("error: %s\n", err)
        os.Exit(1)
    }

    // reversible usage
    hash, err := s.Encode(email)
    if err != nil {
        fmt.Printf("error: %s\n", err)
        os.Exit(1)
    }

    fmt.Printf("hash: %s\n", hash)

    // non-reversible usage
    hash, err = s.MethodEncode(salty64.SHA256, "[email protected]")
    if err != nil {
        fmt.Printf("error: %s\n", err)
        os.Exit(1)
    }
}

salty64's People

Contributors

bit-cmdr avatar

Watchers

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.