expr srand([lindex $argv end-1]) # Fill the lookup table set alphabet {a b c d e f g h i j k l m n o p q r s t u v w x y z \ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z } set unused $alphabet # Iterate through characters foreach letter $alphabet { set pos [expr {int([llength $unused] * rand())}] set cipher($letter) [lindex $unused $pos] set unused [lreplace $unused $pos $pos] } set cipher(\ ) " " foreach letter [split [lindex $argv end] {}] { append cipherText $cipher($letter) } puts $cipherText