crypto

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package crypto implements the following:- Basic encryption using aes and gcm Hmac with sha256 based hashing Random string generation.

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongPasswd = errors.New("crypto: wrong password")

ErrWrongPasswd is the error thrown when wrong password is given.

Functions

func Decrypt

func Decrypt(s, p []byte) ([]byte, error)

Decrypt decrypts "s" with password "p" using aes and gcm.

func Encrypt

func Encrypt(s, p []byte) ([]byte, error)

Encrypt encrypts "s" with password "p" using aes and gcm.

func Generate

func Generate(s int) ([]byte, error)

Generate generates a random byte array of length "s" and returns it. This function is used to generate random passwords.

func Hash

func Hash(s, b []byte) ([]byte, error)

Hash hashes "s" using sha256, appends it to "b" and returns it.

func HmacHash

func HmacHash(s, p, b []byte) ([]byte, error)

HmacHash hashes "s" with password "p" using hmac and sha256, appends it to "b" and returns it.

func HmacVerify

func HmacVerify(s, a []byte) bool

HmacVerify verifies if "s" is equal to "a" in a secure way. Use this for hmac based hashes.

func Verify

func Verify(s, a []byte) bool

Verify verifies if "s" is equal to "a".

Types

This section is empty.

Jump to

Keyboard shortcuts

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