password

package
v0.0.0-...-e797c0d Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2015 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package password manipulates passwords stored in Modular Crypt Format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeBase64

func EncodeBase64(in []byte) (out []byte)

EncodeBase64 encodes the input bytes into standard base64 format.

func EncodeHex

func EncodeHex(in []byte) (out []byte)

EncodeHex encodes the input bytes into hex format.

Types

type ErrorInputPassword

type ErrorInputPassword struct {
	Msg      string //Error message
	Password string //Input password
}

ErrorInputPassword is returned for input passwords that fail validation. The struct can be examined for a possible solution.

func (ErrorInputPassword) Error

func (e ErrorInputPassword) Error() string

type Passwd

type Passwd struct {
	Name   []byte
	Params []byte
	Salt   []byte
	Key    []byte

	// Encoder is a function that encodes Salt and Key into serialized form
	// Defaults to EncoderBase64, but can be changed to EncoderHex or other function.
	Encoder func([]byte) []byte

	// Decoder deserializes the Salt and Key fields.
	// The default recognizes Base64 or Hex.
	// If you replace Encoder with something else, replace Decoder too, possibly with a fallback to the
	// default.
	Decoder func([]byte) ([]byte, error)
}

Passwd is a password separated into components

func New

func New(name []byte) *Passwd

New returns a Passwd struct initialized with the default encoders.

func (*Passwd) Bytes

func (p *Passwd) Bytes() []byte

Bytes produces an encoded password in Modular Crypt Format. The output can be stored and later used to verify the password.

func (*Passwd) Parse

func (p *Passwd) Parse(encoded []byte) (err error)

Parse extracts an encoded password in Modular Crypt Format into a Passwd structure. The input is validated and should match what String() produces.

Jump to

Keyboard shortcuts

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