Last active
September 16, 2019 07:48
-
-
Save Bablzz/08e4588d9c84cc409f359c33114f1fb9 to your computer and use it in GitHub Desktop.
Caesar cypher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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