将输入变为hackerese的javascript代码
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 |
<script> function hackerese() { orgtext=document.getElementById("orgtext").value.toUpperCase(); newtext=document.getElementById("newtext").value; table="4 @ /- Д,8 13 |3,[ < (,d |) [) I> cl,3 € [-,|= £,6 9 <- (.,# /-/ ]-[ )-(,1 ! | ],_/ _],|<,7 1_ |_ ,[V] //,||,0 (),|7,()_,Я,5 $ §,7 +,|_| μ,/,//,>< ×,j,2 %"; temp=table.split(","); table={}; for(var alpha="A".charCodeAt(0);alpha<="Z".charCodeAt(0);alpha++) { table[String.fromCharCode(alpha)]=temp[alpha-"A".charCodeAt(0)].split(" "); } newtext=""; for(i in orgtext) { alpha=orgtext[i]; if(table.hasOwnProperty(alpha)) { rand=Math.random()*10; if(rand<7) newtext+=alpha.toLowerCase(); else newtext+=table[alpha][Math.round(Math.random()*table[alpha].length)]; } else newtext+=alpha; } document.getElementById("newtext").value=newtext; } </script> <div> <p> |-输入-| <p><textarea id=orgtext></textarea> <p> |-输出-| <p><textarea id=newtext></textarea> <p><input type=button onclick="hackerese()" value="ese"> </div> |
将输入变为hackerese的python代码:
python leet.py be cool and be free
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/usr/local/bin/python # -*- coding: utf-8 -*- import sys import string import random org=string.join(sys.argv[1:]).upper() table="4 @ /- Д,8 13 |3,[ < (,d |) [) I> cl,3 € [-,|= £,6 9 <- (.,# /-/ ]-[ )-(,1 ! | ],_/ _],|<,7 1_ |_ ,[V] //,||,0 (),|7,()_,Я,5 $ §,7 +,|_| μ,/,//,>< ×,j,2 %" temp=string.split(table,",") table={} for alpha in range(ord("A"),ord("Z")+1): table[chr(alpha)]=string.split(temp[alpha-ord("A")]," ") new=[] for alpha in org: if table.has_key(alpha): rand=random.randint(1,10) if rand<7: new.append(alpha.lower()) else: new.append(random.choice(table[alpha])) else: new.append(alpha) print string.join(new,"") |