Skip to content

Instantly share code, notes, and snippets.

@Bablzz
Last active Sep 16, 2019
Embed
What would you like to do?
Caesar cypher
package main
import "fmt"
var mes = "test cypeher with digit 6"
func main() {
bs := ([]byte)(mes)
cyp := make([]byte, len(bs))
j := 0
key := (byte)(2)
for i := range bs {
if bs[i] != 32 {
bs[i] = bs[i] + key
}
}
for i := len(bs) - 1; i >= 0; i-- {
cyp[j] = bs[i]
j++
}
fmt.Printf("%v\n", string(bs))
fmt.Printf("%v", string(cyp))
}
// Output =>
// vguv e{rgjgt ykvj fkikv 8
// 8 vkikf jvky tgjgr{e vugv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment