Tr4nsl33tor

GS (20110705) Leet speak is an alternative alphabet appeared on BBS (bulletin board systems) at the end of 1980s as a semi-encrypted mean of communication. Tr4nsl33tor translate text with different level of encryption.

IMG_Transleetor

  # tr4nsl33tor.tcl
  # Author:      Gerard Sookahet
  # Date:        02 Jul 2011
  # Description: Leet speak translator
  
  package require Tk
  bind all <Escape> {exit}
  
  proc Transl33tor level {
   set tab {
      {e 3} {a 4 i 1 o 0} {s $ l £ c ( y ¥ u µ d Ð} {k "|\{" g 9 t 7 z 2 f ƒ} \
      {n "|\\|" w "\\/\\/" h |-| v "\\/" m "|\\/|"} \
      {r ® b ß x )(} {j _| p |° q ¶}
   }
   return [join [lrange $tab 0 [incr level -1]]]
  }
  
  proc Transl33t {w1 w2 level} {
   set s [$w1.t get 0.0 end]
   $w2.t delete 0.0 end
   $w2.t insert end [string map [Transl33tor $level] [string tolower $s]]
  }
  
  set w .tr4nsl33t
  catch {destroy $w}
  toplevel $w
  wm withdraw .
  wm title $w "Tr4nsl33tor"
  set level 1
  
  set f1 [frame $w.f1]
  text $f1.t -height 8 -width 60 -yscrollcommand "$f1.sb set"
  scrollbar $f1.sb -bg black -command "$f1.t yview"
  pack $f1.sb -side right -fill y
  pack $f1.t -expand yes -fill both
  pack $f1 -fill x
  
  set f2 [frame $w.f2]
  label  $f2.l -text Level
  for {set i 1} {$i <= 7} {incr i} {
     radiobutton $f2.rb$i -text $i -variable level -value $i
  }
  button $f2.btrans -text Translate -width 7 -command {Transl33t $::f1 $::f3 $::level}
  button $f2.breset -text Reset -width 7 -command {$::f1.t delete 0.0 end; $::f3.t delete 0.0 end}
  button $f2.bquit -text Exit -width 7 -command exit
  eval pack [winfo children $f2] -side left
  pack $f2 -fill x
  
  set f3 [frame $w.f3]
  text $f3.t -height 8 -width 60 -yscrollcommand "$f3.sb set"
  scrollbar $f3.sb -command "$f3.t yview"
  pack $f3.sb -side right -fill y
  pack $f3.t -expand yes -fill both
  pack $f3 -fill x