MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / encipher

Method encipher

cipher/polybius/polybius.go:78–87  ·  view source on GitHub ↗
(char rune)

Source from the content-addressed store, hash-verified

76}
77
78func (p *Polybius) encipher(char rune) (string, error) {
79 index := strings.IndexRune(p.key, char)
80 if index < 0 {
81 return "", fmt.Errorf("%q does not exist in keys", char)
82 }
83 row := index / p.size
84 col := index % p.size
85 chars := []rune(p.characters)
86 return string([]rune{chars[row], chars[col]}), nil
87}
88
89func (p *Polybius) decipher(chars []rune) (string, error) {
90 if len(chars) != 2 {

Callers 1

EncryptMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected