(chars []rune)
| 87 | } |
| 88 | |
| 89 | func (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 | } |