skip to main content
Quorum
Learn
Hour of Code
Reference
Libraries
Download
Bugs
My Projects
Login
Quorum Login
Login
Cancel
Sign up for an account
"Vigenere Encryption" by Projects
This is a public project. Anyone can view it.
Vigenere Encryption
Code Area
1
boolean running = true text sample = "" text key = "" text newLine = sample:GetLineFeed() text quote = sample:GetDoubleQuote() text constants = "AZ_" integer a = constants:GetUnicodeInteger(0) integer z = constants:GetUnicodeInteger(1) integer underscore = constants:GetUnicodeInteger(2) repeat while running boolean checking = true repeat while checking checking = false sample = input("Enter a text message to encrypt (leave blank to exit)." + newLine + newLine + "Spaces will be changed to underscores, and lowercase letters will be replaced with uppercase letters. Non-alpha, non-space, and non-underscore characters will result in an error.") sample = sample:ToUpperCase() check integer counter = 0 repeat while counter < sample:GetSize() if sample:GetCharacter(counter) = " " if counter + 1 < sample:GetSize() sample = sample:GetSubtext(0, counter) + "_" + sample:GetSubtext(counter + 1) else sample = sample:GetSubtext(0, counter) + "_" end elseif not (sample:GetUnicodeInteger(counter) >= a) and (sample:GetUnicodeInteger(counter) <= z) alert("") end counter = counter + 1 end detect error text temp = input("Error: the text message cannot have characters other than alpha characters, underscores, or spaces.") checking = true end end if sample:IsEmpty() running = false else checking = true repeat while checking checking = false key = input("Enter a secret key." + newLine + newLine + "Once again, spaces will be changed to underscores, and lowercase letters will be replaced with uppercase letters. Non-alpha, non-space, and non-underscore characters will result in an error.") key = key:ToUpperCase() check integer counter = 0 if key:IsEmpty() alert("") end repeat while counter < key:GetSize() if key:GetCharacter(counter) = " " if counter + 1 < key:GetSize() key = key:GetSubtext(0, counter) + "_" + key:GetSubtext(counter + 1) else key = key:GetSubtext(0, counter) + "_" end elseif not (key:GetUnicodeInteger(counter) >= a) and (key:GetUnicodeInteger(counter) <= z) alert("") end counter = counter + 1 end detect error text temp = input("Error: the key cannot have characters other than alpha characters, underscores, or spaces. The key also cannot be empty.") checking = true end end integer counter = 0 text finalSample = "" repeat while counter < sample:GetSize() integer currentSample = 0 if sample:GetUnicodeInteger(counter) = underscore currentSample = z + 1 else currentSample = sample:GetUnicodeInteger(counter) end integer offset = 0 if key:GetUnicodeInteger(counter mod key:GetSize()) = underscore offset = z + 1 - a else offset = key:GetUnicodeInteger(counter mod key:GetSize()) - a end currentSample = currentSample + offset if currentSample = z + 1 currentSample = underscore elseif currentSample > z + 1 currentSample = currentSample - 27 end finalSample = finalSample + finalSample:GetUnicodeValue(currentSample) counter = counter + 1 end output("Key: " + key + newLine + "Plaintext: " + sample + newLine + "Ciphertext: " + finalSample + newLine + newLine) text temp = input("The encrypted text message is as follows:" + newLine + newLine + finalSample) end end
Build (CTRL+B)
Run (CTRL+R)
Stop Program
Save this Project
Project Name:
Save Project
Cancel
Load a Project
Load Project
Cancel
Save
Load
Embed
Output Area