Python: A recipe for cryptic code? Python: Una receta para el críptico código?
I have heard that Python is a great programming language which is so much superior to everything around etc. He oído que Python es un gran lenguaje de programación que es muy superior a todo alrededor de etc
The following code in python is touted as the world’s smallest p2p client & server. El siguiente código en python se promociona como el más pequeño del mundo p2p cliente y servidor.
# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html) # Tinyp2p.py 1.0 (la documentación en http://freedom-to-tinker.com/tinyp2p.html)
import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, EW Felten importación sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, EW Felten
ar,pw,res = (sys.argv,lambda u:hmac.new(sys.argv[1],u).hexdigest(),re.search) ar, pw, res = (sys.argv, lambda u: hmac.new (sys.argv [1], u). hexdigest (), re.search)
pxy,xs = (xmlrpclib.ServerProxy,SimpleXMLRPCServer.SimpleXMLRPCServer) pxy, x = (xmlrpclib.ServerProxy, SimpleXMLRPCServer.SimpleXMLRPCServer)
def ls(p=”"):return filter(lambda n:(p==”")or res(p,n),os.listdir(os.getcwd())) def ls (p =""): regreso filtro (lambda n: (p =="") o res (p, n), os.listdir (os.getcwd ()))
if ar[2]!=”client”: # license: http://creativecommons.org/licenses/by-nc-sa/2.0 si ar [2]! = "cliente": # license: http://creativecommons.org/licenses/by-nc-sa/2.0
myU,prs,srv = (”http://”+ar[3]+”:”+ar[4], ar[5:],lambda x:x.serve_forever()) myU, prs, srv = ( "http://" + ar [3 ]+":"+ ar [4], ar [5:], lambda x: x.serve_forever ())
def pr(x=[]): return ([(y in prs) or prs.append(y) for y in x] or 1) and prs def pr (x =[]): return ([(y en ERP) o prs.append (y) para y por x] o 1) y prs
def c(n): return ((lambda f: (f.read(), f.close()))(file(n)))[0] def c (n): return ((lambda f: (f.read (), f.close ()))( archivo (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 = lambda p, n, a: (p == pw (myU)) y (((n == 0) y pr (a)) o ((n == 1) y [ls (a)]) o c (a))
def aug(u): return ((u==myU) and pr()) or pr(pxy(u).f(pw(u),0,pr([myU]))) ganó a Agosto (u): return ((u == myU) y pr ()) o pr (pxy (u). f (pw (u), 0, pr ([myU])))
pr() and [aug(s) for s in aug(pr()[0])] pr () y [Agosto (s) para s en Agosto (pr () [0])]
(lambda sv:sv.register_function(f,”f”) or srv(sv))(xs((ar[3],int(ar[4])))) (lambda sv: sv.register_function (f, "f") o srv (sv)) (xs ((ar [3], int (ar [4 ]))))
for url in pxy(ar[3]).f(pw(ar[3]),0,[]): para la url en pxy (ar [3]). f (pw (ar [3]), 0 ,[]):
for fn in filter(lambda n:not n in ls(), (pxy(url).f(pw(url),1,ar[4]))[0]): a fn de filtro (lambda n: n no en ls (), (pxy (url). f (pw (url), 1, ar [4])) [0]):
(lambda fi:fi.write(pxy(url).f(pw(url),2,fn)) or fi.close())(file(fn,”wc”)) (lambda fi: fi.write (pxy (url). f (pw (url), 2, fn)) o fi.close ()) (file (fn, "wc"))
Source: Fuente: 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. Comencé mi carrera de programación con el lenguaje ensamblador (escritura pequeña. Com los programas y jugar con cuties como TASM y MASM), luego se trasladó a C, incluso lío con los códigos java byte para la diversión.
But this wonderful gem of a program (displayed above) beat the crap out of me. Sin embargo, esta maravillosa joya de un programa (que se muestra más arriba) batió el crap fuera de mí.
Python, going by this example, looks to me a sure-fire recipe for creating obfuscated code. Python, pasando por este ejemplo, mira a mí un seguro del fuego receta para la creación de código ofuscado. I would rather read 80×86 instructions, thank you very much! Prefiero leer 80 × 86 instrucciones, muchas gracias!
PS. Java programmers, you can relax. Programadores de Java, se puede relajar. Python programmers (oops hackers as per naive bayesian dude) writing such code will never be able to maintain it. Los programadores de Python (oops hackers como por bayesian ingenuo dude) escrito tal código nunca será capaz de mantenerla. 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). Así que sin duda se llama para sustituir a esos "hackers" y de reescritura de toda la cosa en Java (uso la palabra refactoring para conseguir una mejor tracción con la gestión).
Filed under Filed under Humor , Java Software El software de Java , Technology Tecnología , Web , Web Services Web Services | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Enviar artículo
You may also like to read También puede leer |




April 13th, 2005 at 3:55 am 13 de abril de 2005, a las 3:55 am
I’ma java programmer (and an occasioanl python/jython one). Soy un programador de Java (y un occasioanl python / Jython uno). But this is not really fair. Pero esto no es realmente justo. One can write obfuscated code in any language. Uno puede escribir código ofuscado en cualquier idioma. This code is like when you write multiple statments in one line in any C style language (like in java). Este código es como cuando usted escribe múltiples statments en una línea en cualquier idioma estilo C (como en java). Or you can nest a lot of method calls, which you normally don’t do if you wan’t maintanable code. O bien, puede anidar un montón de llamadas método, que normalmente no hacen si wan't maintanable código.
This code is meant to be compact and not readible or maintainable. Este código está destinado a ser compacta y no readible o mantenible. There are no blocks (no indentations) only one liner methods and lambda (inline defined) functions. No hay bloques (sin hendiduras) sólo una línea y métodos de lambda (en línea definida) funciones. Python does look good when you program it in the right, standard style. Python hace lucir bien cuando se programa en el derecho, norma de estilo. 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). Y no hay tal cosa, al igual que con java (aunque hay algunas inconsistencias molestas, como algunas personas y los usos de camellos stdlib caso aquí y allí pone de relieve, etc.)
April 13th, 2005 at 5:06 am 13 de abril de 2005, a las 5:06 am
Be sure to catch the readable rebuke Asegúrese de tomar el reproche de lectura
:
http://www.mechanicalcat.net/richard/log/Python/Ugly_Python
…wonder if that runs in Jython? … Pregunto que si se ejecuta en Jython?
April 13th, 2005 at 5:14 am 13 de abril de 2005, a las 5:14 am
@Laszlo Marai @ Laszlo Marai
> But this is not really fair. > Pero esto no es realmente justo.
Life isn’t fair either La vida no es justa, ya sea
BTW: You mentioned that the code is meant to be compact and not readable or maintable. BTW: Usted ha mencionado que el código está destinado a ser compacta y no puede leer o maintable. Then why did he code it in Python? Entonces ¿por qué el código en Python? Why not in assembly language? ¿Por qué no en ensamblador? It would have been much faster and more compact. Hubiera sido mucho más rápido y más compacto.
Any code written in high level language should be readable and maintable. Cualquier código escrito en lenguaje de alto nivel debería ser legible y maintable.
I seriously doubt you can match this level of obfuscation in Java. I dudar seriamente de que puede igualar este nivel de ofuscación en Java. Heck I can even read the decompiled obfuscated(using standard obfuscators; not by the programmer) java code properly. Heck me puede incluso leer el descompilado obfuscated (usando estándar obfuscators; no por el programador) del código de Java correctamente.
PS: Be sure to check the categories this post is under. PS: Por favor, compruebe las categorías de este puesto bajo.
April 13th, 2005 at 5:32 am 13 de abril de 2005, a las 5:32 am
From Desde 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 importar java.awt .*; importación java.util .*; público de clase C se extiende Frame (Fecha D = new Fecha (); vacío T (Fecha d) (D = d; pintar ();) doble P = Math.PI , A = P / 2, a, c, U =. 05; int W, H, M, R; doble E (int a, int u) (retorno (3 * P / 2 +2 * p * a / u )% (2 * P);) nulo N (Graphics g, q doble, doble s) (g.fillPolygon (nuevo int [] (H (s, q), H (U, q + A), H (U , q +3 * A)), nuevo int [] (J (s, q), J (U, q + A), J (U, q +3 * A)), 3);) public void pintar ( Graphics g) (color C = SystemColor.control; g.setColor (C); g.fillRect (0,0, W = tamaño (). Ancho, H = tamaño (). Altura); W-= 52; H - = 52; R = Math.min (W / 2, H / 2); g.translate (W / 2 +25, H / 2 +36); g.setColor (C.darker ()); para (m = 0; m javac C.java
C> java C C> C Java
Author & Submitter: David M. Hewitt/1999″ Autor & Peticionario: David M. Hewitt / 1999 "
April 13th, 2005 at 6:37 am 13 de abril de 2005, a las 6:37 am
not the shortest p2p app, there is at least a shorter one in ruby and an even shorter one in perl. no el más corto app p2p, hay al menos un menor en un rubí y una más corta en perl.
See Ver
http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/123945
for the first, I can’t find the latter. para la primera, no puedo encontrar la última.
Btw, doing this things in python is more impressive. BTW, ya que lo haga cosas en python es más impresionante.
April 13th, 2005 at 7:08 am 13 de abril de 2005, a las 7:08 am
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. Usted recogió lo que es probablemente el más obsfucated fragmento de código Python en existencia y están tratando de hacer una generalización sobre todo el lenguaje se basa en él. It’s folly. Es una locura.
> Why not in assembly language? > ¿Por qué no en ensamblador? It would have been much faster and more compact. Hubiera sido mucho más rápido y más compacto.
It would have taken longer, required many more lines, and would have been limited to running on a specific platform. Hubiera tenido más tiempo, requiere muchas más líneas, y se han limitado a correr en una plataforma concreta.
> Any code written in high level language should be readable and maintable. > Cualquier código escrito en lenguaje de alto nivel debería ser legible y maintable.
More folly. Más locura. Python syntax *encourages* readable and maintainable code, it doesn’t require it. Python sintaxis * * alienta mantenible y legible el código, no lo necesita.
October 3rd, 2007 at 7:21 am 3 de octubre de 2007, a las 7:21 am
I tend to agree with the artical. Tiendo a estar de acuerdo con el artículo. Have a look at examples in the Python tutorials: ¡Echa un vistazo a los ejemplos en Python tutoriales:
return “;”.join(["%s=%s" % (k, v) for k, v in params.items()]) retorno ";". unirse ([ "% s% s ="% (k, v) por k, v en params.items ()])
This statement could easily be written using a loop and be much easier to understand. Esta declaración podría fácilmente ser escrito utilizando un bucle y ser mucho más fácil de entender. 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. Parece que se enfríen los programadores de Python para tratar de escribir el programa en su totalidad en una sola línea y la sintaxis de la lengua parece estar diseñado de esa manera.
Java uses plain english keywords that makes it less crytic. Java utiliza llanura Inglés palabras clave que lo hace menos crytic.