# $Id: rot13.tcl,v 1.2 2000/12/04 04:17:19 ams Exp $ # Copyright 2000 Abhijit Menon-Sen # proc rot {n} { global rots if {![info exists rots($n)]} { for {set i 0} {$i < 26} {incr i} { eval lappend ltr \ [format "%c %c" [expr 65+$i] [expr 65+($i+$n)%26]] \ [format "%c %c" [expr 97+$i] [expr 97+($i+$n)%26]] } set rots($n) $ltr } return $rots($n) } proc rotn {n s} { array set tr [rot $n] set l [string length $s] for {set i 0} {$i < $l} {incr i} { append t $tr([string index $s $i]) } return $t } proc rot13 {s} { return [rotn 13 $s] }