Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Pure golfed MD5

by mtve (Deacon)
on Aug 14, 2002 at 19:50 UTC ( [id://190213]=obfuscated: print w/replies, xml ) Need Help??

Here is obfuscated pure MD5, ready to put in .megasig :)

Input is on stdin, output is hexadecimal hash. Rules for this golf round are: code must be /^[\t\n -~]$/, input length < 2**32.

It's just a fuse for your ideas, because it will be massively squeezed after someone recalls generative polynomial for MD5 constants. Meanwhile feel free to shave strokes here and there.

#!perl -lp0777 BEGIN{$^H++}@Y=@R[-4..-1]if@R=unpack V68,unpack u,uc q{` M>*1juu:wq^c;<"`D[lz]P:\/?/4jQh='$t8Pj`&51Ow8f(!ik_=$b[%;__^^ Muur)(A&0:Y-qf/v.0wff(0Bt26(E'O9`lt#`45i>)JK'MnE=$"_64q1$`H'F MH=C(^]/GylWa(=8'-\.'#=7T[11:107IXZGxh^_\v0)O9xI,*Hu".?k_@?9q mar)Ag6t,..7]1.j^i*g/wDm@2[Ov<+r_ol9^FRCz)Z'JA3#ou`4=B`0yt-39 My9g;yoA\ha]e5js$1"(i])?_*d.g(y2k.:"3_,-96V62S`r/??3o_]%=A(5/ m?JaoX.8l_a1#`:.a$0a.@gy3]s7r.kv[tm<jd=.&zp$c16>)j\wo_mRzf'94 ",a};$_.=v128;//;for(/\C{57,64}/g,pack a56V,$',8*y///c-8){@V= unpack V16,$_.v0 x8;@_=@Y;for$K(0..3){$I=(0,1,5)[$K];($D,$A,$ B,$C)=@_[-$_|-4..2],$_[-$_&3]=(($D+=($A&$B|~$A&$C,$A&$C|$B&~$ C,$A^$B^$C,$B^($A|~$C))[$K]+$V[$I&15]+$R[$K*16+$_])<<($N=ord( (GlqvEIn4DkPWfjOU=~/./g)[$K*4+$_%4])%32)|2**$N-1&$D>>32-$N)+$ A,$I+=(1,5,3,7)[$K]for 0..15}map$_+=shift@_,@Y}$_=unpack H64, pack V4,@Y

Replies are listed 'Best First'.
Re: Pure golfed MD5
by mtve (Deacon) on Apr 06, 2003 at 13:54 UTC

    Duh, v128 plays very bad joke on v5.8.0. Fixed and improved version follows (418):

    #!perl -lp0777 sub n{unpack$_[0],pop}sub f{"@_"%2**32}@Y=n V4,n u,'0`2-%9XFKS>_^W+J8= +E0R$';$_ .=pack Bx.(55- y///c&63).VV,1,8*y///c;s!\C{64}!@V=n V16,$&;@:=@Y;$_='f +orK(0..3) {(C,D,A,B)=@:=@:[-1..2],$:[1]=fA+((D=fD+(A&B|~A&C,A&C|B&~C,A^B^C,A|~C^ +B)[K]+V[K **2.4%13+(1+K+K%2*3)*_&15]+int 2**32*abs sinK*16+_+1)<<(N=31&n x.(K*4+ +_%4).c, glqvein4dkpwfjou)|D>>32-N)for 0..15}_=f_+shift@:for@Y';s/[A-V_]/\$$&/g +;$_!eeg;$ _=n H64,pack V4,@Y

    P.S. April 14th. Legacy support costs too much, i decided to drop it. v5.8.0 only version is 403 and fits into five lines:

    #!perl -lp0777 sub n{unpack$_[0],pop}sub f{"@_"%2**32}@Y=n V4,n u,'0`2-%9XFKS>_^W+J8= +E0R$';$_= pack'a*Bx8x!64X8VV',$_,1,8*y///c;s!\C{64}!$_='forK(0..3){(C,D,A,B)=@:= +@:[-1..2] ,$:[1]=fA+((D=fD+(A&B|~A&C,A&C|B&~C,A^B^C,A|~C^B)[K]+V[K**2.55+(1+K+K% +2*3)*_&15 ]+2**32*abs sin++$@)<<(N=31&n x.(K*4+_%4).c,glqvein4dkpwfjou)|D>>32-N) +forE..15} _=f_+shift@:for@Y';@V=n V16,$&;@:=@Y;s/[A-V_]/\$$&/g;$_!eeg;$_=n H64,p +ack V4,@Y

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://190213]
Approved by dws
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-23 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found