Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -3,21 +3,21 @@ package require Tcl 8.6; # Or TclOO package for 8.5
|
|||
oo::class create Caesar {
|
||||
variable encryptMap decryptMap
|
||||
constructor shift {
|
||||
for {set i 0} {$i < 26} {incr i} {
|
||||
# Play fast and loose with string/list duality for shorter code
|
||||
append encryptMap [format "%c %c %c %c " \
|
||||
[expr {$i+65}] [expr {($i+$shift)%26+65}] \
|
||||
[expr {$i+97}] [expr {($i+$shift)%26+97}]]
|
||||
append decryptMap [format "%c %c %c %c " \
|
||||
[expr {$i+65}] [expr {($i-$shift)%26+65}] \
|
||||
[expr {$i+97}] [expr {($i-$shift)%26+97}]]
|
||||
}
|
||||
for {set i 0} {$i < 26} {incr i} {
|
||||
# Play fast and loose with string/list duality for shorter code
|
||||
append encryptMap [format "%c %c %c %c " \
|
||||
[expr {$i+65}] [expr {($i+$shift)%26+65}] \
|
||||
[expr {$i+97}] [expr {($i+$shift)%26+97}]]
|
||||
append decryptMap [format "%c %c %c %c " \
|
||||
[expr {$i+65}] [expr {($i-$shift)%26+65}] \
|
||||
[expr {$i+97}] [expr {($i-$shift)%26+97}]]
|
||||
}
|
||||
}
|
||||
|
||||
method encrypt text {
|
||||
string map $encryptMap $text
|
||||
string map $encryptMap $text
|
||||
}
|
||||
method decrypt text {
|
||||
string map $decryptMap $text
|
||||
string map $decryptMap $text
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue