pbkdf2

package module
v0.0.0-...-ea6ec7c Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 6 Imported by: 0

README

Go PBKDF2 Implementation

Wikipedia

This is a simple PBKDF2 implementation in golang.

Encryption

To encrypt a password use the following code: 'pbkdf2.Encrypt(password, saltLenght, iterations, hashAlgorithm)' password is the password to be encrypted. string format saltLenght is the lenght of the salt to be generated. unsigned int format(number of bytes) iterations is the number of iterations to be used. unsigned int format hashAlgorithm is any hash Algorithm compatible with crypto package(type crypto.Hash).

Verification

To verify a password digest use the following code: 'pbkdf2.Verify(encryptedPassword, password, hashAlgorithm)' encryptedPassword is the encrypted password to be verified. string format password is the password to be verified. string format hashAlgorithm is any hash Algorithm compatible with crypto package(type crypto.Hash), must be the same used on the encryption.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encrypt

func Encrypt(password string, saltSize, iterationCount uint, hash crypto.Hash) (string, error)

Encrypt encrypts a password using PBKDF2 algorithm The encrypted password is returned in the format: salt:iterationCount:hashedPassword The salt is a hexadecimal string The iterationCount is an integer The hashedPassword is a hexadecimal string The saltSize is the size of the salt in bytes The iterationCount is the number of iterations The hash is the hash function to be used(can be any crypto.Hash)

func Verify

func Verify(encryptedPassword, password string, hash crypto.Hash) (bool, error)

Verify verifies if a password matches an encrypted password The encrypted password must be in the format: salt:iterationCount:hashedPassword The salt is a hexadecimal string The iterationCount is an integer The hashedPassword is a hexadecimal string The hash is the hash function to be used(can be any crypto.Hash) it will throw an error if the encrypted password is not in the correct format

Types

This section is empty.

Directories

Path Synopsis
cmd
pbkdf2
PBKDF2 (Password-Based Key Derivation Function 2) command line tool.
PBKDF2 (Password-Based Key Derivation Function 2) command line tool.

Jump to

Keyboard shortcuts

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