cipher

package
v0.0.0-...-61ad9b3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package cipher contains implementations of various toy ciphers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func A1Decode

func A1Decode(n int) rune

A1Decode decodes a number in the range [1-26] using the A=1, ..., Z=26 substitution cipher.

func A1Encode

func A1Encode[T constraints.Integer](n T) int

A1Encode encodes a rune in the range [A-Za-z] using the A=1, ..., Z=26 substitution cipher.

func CBF

func CBF(s string) []int

CBF encodes a string into a slice of integers. CBF encoding is similar to A1Encode, but done mod 10.

func KeywordToMatrix

func KeywordToMatrix(s string, horizontal bool) [5][5]byte

func ROT

func ROT(n int, w string) string

ROT rotates w by n letter. ROT(13, "terra") = "green". Currently only handles lowercase letters.

Types

type FourSquare

type FourSquare struct {
	// contains filtered or unexported fields
}

1 2 4 3

func NewFourSquare

func NewFourSquare(key1, key2 string, horizontal bool) *FourSquare

NewFourSquare creates a new four square cipher instance. GC49KY3 uses horizontal = false. CacheSleuth uses horizontal = true.

func (*FourSquare) Decode

func (f *FourSquare) Decode(s string) (string, error)

func (*FourSquare) Encode

func (f *FourSquare) Encode(s string) (string, error)

func (*FourSquare) String

func (f *FourSquare) String() string

type SixSquare

type SixSquare struct {
	// contains filtered or unexported fields
}

func NewSixSquare

func NewSixSquare(a, b, c string) *SixSquare

func NewSixSquareFromMatrices

func NewSixSquareFromMatrices(two, four, six [5][5]byte) *SixSquare

func (*SixSquare) Decode

func (six *SixSquare) Decode(s string) (string, error)

func (*SixSquare) Encode

func (six *SixSquare) Encode(s string) (string, error)

func (*SixSquare) String

func (s *SixSquare) String() string

Jump to

Keyboard shortcuts

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