lesson11

command
v0.0.0-...-8eea285 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Experiment: cipher.go To send ciphered messages, write a program that ciphers plain text using a keyword: plainText := "your message goes here" keyword := "GOLANG" Bonus: rather than write your plain text message in uppercase letters with no spaces, use the strings.Replace and strings.ToUpper functions to remove spaces and uppercase the string before you cipher it. Once you’ve ciphered a plain text message, check your work by deciphering the ciphered text with the same keyword. Use the keyword "GOLANG" to cipher a message and post it to the forums for Get Program- ming with Go at forums.manning.com/forums/get-programming-with-go.

Experiment: decipher.go * Write a program to decipher the ciphered text cipherText := "CSOITEUIWUIZNSROCNKFD" keyword := "GOLANG" To keep it simple, all characters are uppercase English letters for both the text and keyword. * The strings.Repeat function may come in handy. Give it a try, but also complete this exercise without importing any packages other than fmt to print the deciphered message. * Try this exercise using range in a loop and again without it. Remember that the range keyword splits a string into runes, whereas an index like keyword[0] results in a byte. * You can only perform operations on values of the same type, but you can convert one type to the other (string, byte, rune). * To wrap around at the edges of the alphabet, the Caesar cipher exercise made use of a comparison. Solve this exercise without any if statements by using modulus. * If you recall, modulus gives the remainder of dividing two numbers. For example, 27 % 26 is 1, keeping numbers within the 0–25 range. Be careful with negative numbers, though, as -3 % 26 is still -3.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL