-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaesar.grph
More file actions
37 lines (33 loc) · 1.05 KB
/
caesar.grph
File metadata and controls
37 lines (33 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#requires GRPH 1.10
#import strutils
final integer KEY = 3
/// Encrypts the given character using the KEY constant and the given range.
/// @param char The character, as a codepoint
/// @param min The lowest codepoint to encrypt
/// @param max The highest codepoint to encrypt, or min + 27 by default
#function integer encryptLetter[integer char, integer min, integer max = min + 27]
#if char > min && char < max
char += KEY
#if char >= max
char -= 26
#return char
Text t = Text("Enter a text to convert" 50,100 font[20] color.BLACK)
validate: t
Rectangle bBack = Rectangle(100,130 80,30 color[128 128 128])
Text bText = Text("Cypher" 110,155 font[20] color.WHITE)
Group button = Group("Button" bBack bText)
validate: button
#while true
#while button != getSelectedShape[]
wait: 15
string str = t.name
string result = ""
integer i = 0
#while i < str.length
integer char = charToInteger[substring[str i]]
char = encryptLetter[char 64]
char = encryptLetter[char 96]
result = result + integerToChar[char]
i += 1
t.name = result
resetSelectedShape: