twofactor

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2015 License: MIT Imports: 2 Imported by: 6

README

twofactor - Two-factor authentication library

wercker status Coverage Status

go-twofactor is a library for handling two-factor authentication in Go.
To use the library, you need to install one of the implementations below.

TOTP

GoDoc

This implementation generates and verifies codes using the time-based one time password (TOTP) algorithm specified in RFC6238.

go get gopkg.in/zhevron/go-twofactor.v1/totp

License

go-twofactor is licensed under the MIT license.

Documentation

Overview

Package twofactor contains support functions and types for two-factor authentication.

This package provides shared structs and functions for all implementations.

To generate a new secret for 2FA, use the NewSecret method:

import "gopkg.in/zhevron/go-twofactor.v1"
secret := twofactor.NewSecret(0)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int64ToBytes

func Int64ToBytes(n int64) []byte

Int64ToBytes converts a 64-bit integer to a 8-byte slice.

Types

type Secret

type Secret string

Secret wraps a string with functions to generate a cryptographically secure secret.

func NewSecret

func NewSecret(length int) (Secret, error)

NewSecret generates a cryptograpically secure string of the given length. If the length provided is 0 or less, it will default to a length of 10.

func (Secret) Bytes

func (s Secret) Bytes() ([]byte, error)

Bytes decodes the secret into a byte slice.

func (Secret) String

func (s Secret) String() string

String returns the secret as a string.

Directories

Path Synopsis
Package totp contains an RFC6238 implementation of time-based one time passwords.
Package totp contains an RFC6238 implementation of time-based one time passwords.

Jump to

Keyboard shortcuts

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