crypt

package
v0.7.23 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package crypt provides utilities for creating hashes, random strings, password encryption

Index

Constants

This section is empty.

Variables

View Source
var (
	// AlphaUpper all upper alphas chars
	AlphaUpper = RandomSource("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
	// AlphaLower all lowers alphas chars
	AlphaLower = RandomSource("abcdefghijklmnopqrstuvwxyz")
	// AlphaUpperLower all upper and lowers aplhas chars
	AlphaUpperLower = RandomSource("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
	// AlphaUpperLowerNumeric all upper lowers alphas and numerics
	AlphaUpperLowerNumeric = RandomSource("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz")
	// AlphaUpperLowerNumericSpecial all upper lowers alphas, numerics and special chars
	AlphaUpperLowerNumericSpecial = RandomSource("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456890" +
		"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")
)

Functions

func CryptPassword

func CryptPassword(password []byte) ([]byte, error)

CryptPassword hashes a password with bcrypt and a given cost

func GenerateSalt

func GenerateSalt() []byte

GenerateSalt generates a random salt with alphanumerics and some special characters

func RandomHash

func RandomHash(length int) string

RandomHash returns a random SHA-512 hash

func RandomSecureKey

func RandomSecureKey(length int) []byte

RandomSecureKey returns random character with given length

Types

type RandomSource

type RandomSource string

RandomSource string containing which characters should be considered when generating random sequences

func (RandomSource) RandomSequence

func (r RandomSource) RandomSequence(length int) []byte

RandomSequence returns random character with given length;

Jump to

Keyboard shortcuts

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