MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / decipher

Method decipher

cipher/polybius/polybius.go:89–102  ·  view source on GitHub ↗
(chars []rune)

Source from the content-addressed store, hash-verified

87}
88
89func (p *Polybius) decipher(chars []rune) (string, error) {
90 if len(chars) != 2 {
91 return "", fmt.Errorf("the size of \"chars\" must be even")
92 }
93 row := strings.IndexRune(p.characters, chars[0])
94 if row < 0 {
95 return "", fmt.Errorf("%c does not exist in characters", chars[0])
96 }
97 col := strings.IndexRune(p.characters, chars[1])
98 if col < 0 {
99 return "", fmt.Errorf("%c does not exist in characters", chars[1])
100 }
101 return string(p.key[row*p.size+col]), nil
102}

Callers 1

DecryptMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected