security

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OneTimePad

type OneTimePad struct{}

OneTimePad is an implementation of the One-Time Pad information security algorithm.

Important security considerations: A key should never be used more than once, and it should be securely disposed of once it has been used.

func NewOneTimePad

func NewOneTimePad() *OneTimePad

NewOneTimePad creates a new OneTimePad.

func (*OneTimePad) Decode

func (o *OneTimePad) Decode(message, key []byte) []byte

Decode decodes a message using a single-use key.

The length of the key must be greater than or equal to the length of the message.

func (*OneTimePad) DecodeString

func (o *OneTimePad) DecodeString(message, key string) string

DecodeString calls Decode with the message and key bytes.

func (*OneTimePad) Encode

func (o *OneTimePad) Encode(message, key []byte) []byte

Encode encodes a message using a single-use key.

The length of the key must be greater than or equal to the length of the message.

func (*OneTimePad) EncodeString

func (o *OneTimePad) EncodeString(message, key string) string

EncodeString calls Encode with the message and key bytes.

func (*OneTimePad) GenerateKey

func (o *OneTimePad) GenerateKey(length int) []byte

GenerateKey generates a key with a given length.

type OneTimeRunes

type OneTimeRunes struct {
	Chars []rune
	// contains filtered or unexported fields
}

OneTimeRunes is an implementation of the One-Time Pad information security algorithm that uses a custom alphabet instead of bytes.

Important security considerations: A key should never be used more than once, and it should be securely disposed of once it has been used.

func NewDefaultRunes

func NewDefaultRunes() *OneTimeRunes

NewDefaultRunes creates a new OneTimeRunes with the default characters.

Characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:;,.!? (space)

func NewOneTimeRunes

func NewOneTimeRunes(chars []rune) *OneTimeRunes

NewOneTimeRunes creates a new OneTimeRunes with the specified characters.

func (*OneTimeRunes) Decode

func (o *OneTimeRunes) Decode(message, key []rune) []rune

Decode decodes a message using a single-use key.

The length of the key must be greater than or equal to the length of the message.

func (*OneTimeRunes) DecodeString

func (o *OneTimeRunes) DecodeString(message, key string) string

DecodeString calls Decode with the message and key characters.

func (*OneTimeRunes) Encode

func (o *OneTimeRunes) Encode(message, key []rune) []rune

Encode encodes a message using a single-use key.

The length of the key must be greater than or equal to the length of the message.

func (*OneTimeRunes) EncodeString

func (o *OneTimeRunes) EncodeString(message, key string) string

EncodeString calls Encode with the message and key characters.

func (*OneTimeRunes) GenerateKey

func (o *OneTimeRunes) GenerateKey(length int) []rune

GenerateKey generates a key with a given length.

Jump to

Keyboard shortcuts

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