Python: A recipe for cryptic code? 파이썬 : 비밀 코드를위한 레시피?
I have heard that Python is a great programming language which is so much superior to everything around etc. 나는 파이썬는 위대한 프로그래밍 언어를 들었는 주위의 모든 등보다 월등하게 우위를 많이
The following code in python is touted as the world’s smallest p2p client & server. 다음과 같은 코드를 파이썬으로 세계 최소형 강매한 p2p는 클라이언트 및 서버합니다.
# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html) # tinyp2p.py 1.0 (문서를 http://freedom-to-tinker.com/tinyp2p.html)
import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, EW Felten 수입 시스템, 운영 체제, simplexmlrpcserver, xmlrpclib, 레, hmac # (c) 2004, 뉴 felten
ar,pw,res = (sys.argv,lambda u:hmac.new(sys.argv[1],u).hexdigest(),re.search) 착, 주, 사업 = (sys.argv, 람다 유 : hmac.new (sys.argv [1], u). hexdigest (), re.search)
pxy,xs = (xmlrpclib.ServerProxy,SimpleXMLRPCServer.SimpleXMLRPCServer) pxy, xs = (xmlrpclib.serverproxy, simplexmlrpcserver.simplexmlrpcserver)
def ls(p=”"):return filter(lambda n:(p==”")or res(p,n),os.listdir(os.getcwd())) def 저 (p =""): 반환 필터 (람다 n : (p =="") 또는 사업 (p, 아), os.listdir (os.getcwd ()))
if ar[2]!=”client”: # license: http://creativecommons.org/licenses/by-nc-sa/2.0 만약 착 [2]! = "클라이언트": # 라이센스 : http://creativecommons.org/licenses/by-nc-sa/2.0
myU,prs,srv = (”http://”+ar[3]+”:”+ar[4], ar[5:],lambda x:x.serve_forever()) 최근에는, 푸에르 토리코, srv = ( "http://"+ 착 [3 ]+":"+ 착 [4], 착 [5 :], 람다 x : x.serve_forever ())
def pr(x=[]): return ([(y in prs) or prs.append(y) for y in x] or 1) and prs def 홍보 (x =[]): 반환 ([(그리고이 푸에르 토리코) 또는 prs.append (그리고)을 그리고이 x] 또는 1)와 푸에르 토리코
def c(n): return ((lambda f: (f.read(), f.close()))(file(n)))[0] def c (n) : 반환 ((람다 f : (f.read (), f.close ()))( 파일 (n))) [0]
f=lambda p,n,a:(p==pw(myU))and(((n==0)and pr(a))or((n==1)and [ls(a)])or c(a)) f = 람다 p, 아의 : (p == 주 (최근에는)) 및 (((n == 0), 홍보 (가)) 또는 ((n == 1)와 [그 (가)]) 또는 c (가))
def aug(u): return ((u==myU) and pr()) or pr(pxy(u).f(pw(u),0,pr([myU]))) def 8월 (u) : 반환 ((u == 최근에는) 및 홍보 ()) 또는 홍보 (pxy (u). 층 (주 (u), 0, 홍보 ([최근에는])))
pr() and [aug(s) for s in aug(pr()[0])] 홍보 ()와 [8월 (영어)에 대한의 8월 (홍보 () [0])]
(lambda sv:sv.register_function(f,”f”) or srv(sv))(xs((ar[3],int(ar[4])))) (람다 스웨덴어 : sv.register_function (f, "이름") 또는 srv (스웨덴어)) (xs ((착 [3], int (착 [4 ]))))
for url in pxy(ar[3]).f(pw(ar[3]),0,[]): url을위한 pxy (착 [3]). 층 (주 (착 [3]), 0 ,[]):
for fn in filter(lambda n:not n in ls(), (pxy(url).f(pw(url),1,ar[4]))[0]): fn을위한 필터 (람다 n : 특정 n에서 그 (), (pxy (). 층 (주 (), 1, 착 [4])) [0]) :
(lambda fi:fi.write(pxy(url).f(pw(url),2,fn)) or fi.close())(file(fn,”wc”)) (람다 나는 : fi.write (pxy (). 층 (주 (), 2, fn)) 또는 fi.close ()) (파일 (fn, "화장실"))
Source: 출처 : TinyP2P tinyp2p
I started my programming career with assembly language (writing tiny .com programs and playing with cuties like masm and tasm), then moved to C, even mess with java byte codes for fun. 나는 내 프로그래밍 경력을 시작 어셈블리 언어 (서면 작은합니다. masm com 프로그램과 노는 거라 생각하고 tasm), 다음으로 이동 c, 심지어 자바 바이트 코드를 즐거움을 혼란하게합니다.
But this wonderful gem of a program (displayed above) beat the crap out of me. 그러나이 훌륭한 보석의 프로그램 (표시 위) 한방에 떨어질 뻔했네.
Python, going by this example, looks to me a sure-fire recipe for creating obfuscated code. 파이썬, 그이 들어, 내 눈에 - 화재 조리법에 대한 확실한 판단이 흐려지게 코드를 생성합니다. I would rather read 80×86 instructions, thank you very much! 80 × 86 지침을 읽고 난 차라리, 대단히 감사합니다!
PS. ps. Java programmers, you can relax. 자바 프로그래머, 휴식하실 수있습니다. Python programmers (oops hackers as per naive bayesian dude) writing such code will never be able to maintain it. 파이썬 프로그래머 (죄송합니다 나이브베이스에 따라 해커 야) 기록 이러한 코드는 절대로 그것을 유지할 수있습니다. So you will definitely be called in to replace such “hackers” and rewrite the whole thing in Java (use the word refactoring to get better traction with management). 그럼에도 전화를 교체는 반드시 이러한 "해커"그리고 전부를 재작 성 자바 (리팩터링에 단어를 사용하여 더 나은 트랙션과 관리)를합니다.
Filed under 밑에 Humor 유머 감각 , Java Software 자바 소프트웨어 , Technology 기술 , Web 웹 , Web Services 웹 서비스 | |
| |
RSS 2.0 rss 2.0 | |
Email this Article 전자 우편이 문서
You may also like to read 같은를 읽을 수있습니다 |




April 13th, 2005 at 3:55 am 2005년 4월 13일에서 오전 3시 55분
I’ma java programmer (and an occasioanl python/jython one). 저는 자바 프로그래머 (및 occasioanl 파이썬 / jython 1). But this is not really fair. 하지만, 이것은 정말 공평합니다. One can write obfuscated code in any language. 언어에 상관없이 읽을 수없는 코드를 하나 쓸 수있습니다. This code is like when you write multiple statments in one line in any C style language (like in java). 이 코드는 여러 개의 statments를 작성할 때는 한 줄에 같이 어떠한 c 스타일 언어 (같이 자바)를합니다. Or you can nest a lot of method calls, which you normally don’t do if you wan’t maintanable code. 아니면 둥지를하실 수있습니다 많은 메서드 호출, 그리고 당신 wan't maintanable 코드를 정상적으로하지 않으면합니다.
This code is meant to be compact and not readible or maintainable. 이 코드는 압축이 아닌 의미하는 것이 readible 또는 유지 관리합니다. There are no blocks (no indentations) only one liner methods and lambda (inline defined) functions. 이없습니다 블록 (아니오 들여쓰기) 만 한 라이너 방법 및 람다 (인라인 정의) 기능을합니다. Python does look good when you program it in the right, standard style. 파이썬이 좋아 보이는 프로그램을 때 그것의 오른쪽, 표준 스타일. And there is such a thing, just as with java (though there are some annoying inconsistencies, like some people and the stdlib uses camel case here and underscores there, etc). 그리고 그런 게있다, 그냥 같이 자바 (비록 몇 가지 짜증나는 일관성이 같은 사례는 여기에 어떤 사람과 낙타과 밑줄을 사용 stdlib가 등)을합니다.
April 13th, 2005 at 5:06 am 2005년 4월 13일에서 오전 5시 6분
Be sure to catch the readable rebuke 읽을 수를 반드시 비난을 잡아라
:
http://www.mechanicalcat.net/richard/log/Python/Ugly_Python http://www.mechanicalcat.net/richard/log/python/ugly_python
…wonder if that runs in Jython? jython… 궁금해에서 실행되는가?
April 13th, 2005 at 5:14 am 2005년 4월 13일에서 오전 5시 14분
@Laszlo Marai @ laszlo marai
> But this is not really fair. >하지만, 이것은 정말 공평합니다.
Life isn’t fair either 인생은 공평 중
BTW: You mentioned that the code is meant to be compact and not readable or maintable. btw : 당신이 말한 그 다음 코드가 의미하는 것이 콤팩트하며 읽을 수 없다 또는 maintable합니다. Then why did he code it in Python? 그렇다면 왜에서 그 코드를 파이썬? Why not in assembly language? 어셈블리 언어를 왜? It would have been much faster and more compact. 그렇지 않았 훨씬 빠르고 압축합니다.
Any code written in high level language should be readable and maintable. 높은 수준 언어로 작성된 모든 코드를 읽을 수 있어야하고 maintable합니다.
I seriously doubt you can match this level of obfuscation in Java. 나는 이러한 수준의 심각하게 의심하실 수있습니다 난처는 자바와 일치합니다. Heck I can even read the decompiled obfuscated(using standard obfuscators; not by the programmer) java code properly. 도무지 판단이 흐려지게 할 수도 읽을 디컴파일 (표준 obfuscators를 사용하여, 프로그래머를 통해 할 수는없습니다) 자바 코드를 적절하게합니다.
PS: Be sure to check the categories this post is under. ps :이 게시물은 반드시 아래의 카테고리를 확인합니다.
April 13th, 2005 at 5:32 am 2005년 4월 13일에서 오전 5시 32분
From 로부터 http://www.gamedev.net/hosted/javaextreme/obfpoll.htm :
import java.awt.*;import java.util.*;public class C extends Frame{Date D=new Date();void T(Date d){D=d;repaint();}double P=Math.PI,A=P/2,a,c,U=.05;int W,H,m,R;double E(int a,int u){return(3*P/2+2*P*a/u)%(2*P);}void N(Graphics g,double q,double s){g.fillPolygon(new int[]{H(s,q),H(U,q+A),H(U,q+3*A)},new int[]{J(s,q),J(U,q+A),J(U,q+3*A)},3);}public void paint(Graphics g){Color C=SystemColor.control;g.setColor(C);g.fillRect(0,0,W=size().width,H=size().height);W-=52;H-=52;R=Math.min(W/2,H/2);g.translate(W/2+25,H/2+36);g.setColor(C.darker());for(m=0;m javac C.java 수입 java.awt .*; 수입 java.util .*; 공용 클래스 c 확장 프레임 (날짜 패 = 새 날짜 (); 무효 톤 (날짜 패) (패 = 패; 다시 ();) 더블 p = math.pi 는 = π / 2, 애, c, u =. 05; int 승, 반장님, 잔글, 연구; 더블 이메일 (int a, int u) (반환 (3 * π / 2 +2 * p * 2 / u ) % (2 * p);) 무효 n (그래픽 그램을 두 질문을 두 시내) (g.fillpolygon (새 int [] (홈 (시내, 큐), 홈 (u, 큐 +), 홈 (u , 큐 * 3)), 새로운 int [] (일본 (시내, 큐), 일본 (u, 큐 +), 일본 (u, 큐 * 3)), 3);) 공공 무효 그림판 ( 그래픽 g) (색상 c = systemcolor.control; g.setcolor (c); g.fillrect (0,0, 승 = 크기 (). 너비, 홈 = 크기 (). 높이); 승 - = 52; 홈 - = 52; 연구 = math.min (승 / 2, 홈 / 2); g.translate (폭 / 2 +25, 반장님 / 2 +36); g.setcolor (c.darker ());을 (少= 0; m javac c.java
C> java C c> 자바 c
Author & Submitter: David M. Hewitt/1999″ 저자 및 제출자 : 데이비드 m. 휴이트 / 1999 "
April 13th, 2005 at 6:37 am 2005년 4월 13일에서 오전 6시 37분
not the shortest p2p app, there is at least a shorter one in ruby and an even shorter one in perl. p2p 최단없습니다 애플, 저기가 적어도 하나의 짧은 펄 루비와 짝수 짧아 중 1.
See 보다
http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/123945
for the first, I can’t find the latter. 은 첫째로, 나는 후자를 찾을 수없습니다.
Btw, doing this things in python is more impressive. 그런데, 이렇게 파이썬이 더 인상적인 일들을합니다.
April 13th, 2005 at 7:08 am 2005년 4월 13일에서 오전 7시 8분
You picked what is probably the single most obsfucated chunk of Python code in existence and are attempting to make a generalization about the entire language based on it. 그 중 하나를 선택한 대부분의 obsfucated 무엇입니까 덩어리하려고 시도하는 파이썬 코드가 존재와 언어의 전체 내용을 기반으로 일반화 그것합니다. It’s folly. 그것의 어리석음합니다.
> Why not in assembly language? > 어셈블리 언어를 왜? It would have been much faster and more compact. 그렇지 않았 훨씬 빠르고 압축합니다.
It would have taken longer, required many more lines, and would have been limited to running on a specific platform. 그것이 너무 오래, 필수 많은 라인, 그리고 됐을 특정 플랫폼에서 실행되는로 제한합니다.
> Any code written in high level language should be readable and maintable. > 높은 수준 언어로 작성된 모든 코드를 읽을 수 있어야하고 maintable합니다.
More folly. 더 많은 어리석음합니다. Python syntax *encourages* readable and maintainable code, it doesn’t require it. 파이썬 구문을 * 격려 * 판독 및 유지 관리가 코드를 요구하는 것은하지 않습니다.
October 3rd, 2007 at 7:21 am 2007년 10월 3일에서 오전 7시 21분
I tend to agree with the artical. 나는이 문서에 동의하는 경향이있습니다. Have a look at examples in the Python tutorials: 파이썬의 사례를 살펴보 자습서 :
return “;”.join(["%s=%s" % (k, v) for k, v in params.items()]) 반환 ";"합니다. 조인 ([ "%의 = %의"% (k, 승)를 k, 승의 params.items ()])
This statement could easily be written using a loop and be much easier to understand. 이 문장은 쉽게 쓸 루프를 사용하여보다 쉽게 이해할 수있습니다. It seems to be cool to Python programmers try to write the entire program in one line and the syntax of the language seems to be designed that way. 파이썬 프로그래머가 유행으로 보인다의 전체 프로그램을하려고 한 줄에 쓰기의 언어와 구문을 그런식으로 설계된 것 같습니다.
Java uses plain english keywords that makes it less crytic. 자바를 사용 했다며 키워드를 만드는 편이 덜 crytic합니다.