security

package
v0.0.0-...-c859fe7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2015 License: MIT Imports: 6 Imported by: 0

README

Security

This package implements a few functions regarding security.

package main

import (
	"fmt"

	"github.com/mssola/go-utils/security"
)

func main() {
	// PasswordSalt & PasswordMatch.
	salted := security.PasswordSalt("1234")
	fmt.Printf("%v\n", security.PasswordMatch(salted, "123"))  // => false
	fmt.Printf("%v\n", security.PasswordMatch(salted, "1234")) // => true

	// NewAuthToken. It generates a pseudo-random authentication string. This
	// string can be used to create a cookie store for safe sessions. It can
	// also be used as an authentication token.
	fmt.Printf("%v\n", security.NewAuthToken())
}

Copyright © 2014-2015 Miquel Sabaté Solà, released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthToken

func NewAuthToken() string

Public: Returns a new pseudo-random authentication token as a string.

func PasswordMatch

func PasswordMatch(hashed, password string) bool

Public: check if the given password matches with the given hash. Returns true if the hashed version and the password match, false otherwise.

func PasswordSalt

func PasswordSalt(password string) string

Public: generate a salt for the given password. Returns a string containing the salted version of the given password.

Types

This section is empty.

Jump to

Keyboard shortcuts

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