Skip to content

Instantly share code, notes, and snippets.

@thelissimus
Created November 16, 2024 19:43
Show Gist options
  • Select an option

  • Save thelissimus/de30b456581824661a12b6a0794bc38d to your computer and use it in GitHub Desktop.

Select an option

Save thelissimus/de30b456581824661a12b6a0794bc38d to your computer and use it in GitHub Desktop.
Vigenère Cipher exntended to support UTF, implemented in Go.
import (
"fmt"
"strings"
)
func cypher(str string, key string) string {
s, ix := new(strings.Builder), 0
for _, cs := range str {
s.WriteRune(cs + rune(key[ix%len(key)]))
ix++
}
return s.String()
}
func decypher(str string, key string) string {
s, ix := new(strings.Builder), 0
for _, cs := range str {
s.WriteRune(cs - rune(key[ix%len(key)]))
ix++
}
return s.String()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment