procmail
[Top] [All Lists]

Re: base64-decoding (v.0.99) with 'just' procmail

2004-03-05 16:52:16
Toen ik Gary Funck kietelde, kwam er dit uit:
Ruud H.G. van Tol:

# Filename: base64.rc.inc
# -----------------------

asc = " !\"#$%&()*+,-./0123456789[...]"
b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ[...]"
 
Don't try this at home, folks. <g>
Amazing, Ruud. Two thumbs up.

Thanks. It was fun to make. It took me about 4 hours to get 
it as-is.

A bottle-neck was the DIV operation, in procmail it works 
like this:

   x DIV y  = z
  -- --- -- ---
   1 DIV 16 = 1
  15 DIV 16 = 1
  16 DIV 16 = 1
  31 DIV 16 = 1
  32 DIV 16 = 2
  47 DIV 16 = 2
  48 DIV 16 = 3
  
But if x < y than z should be 0, so I had to put that in a 
separate step. (see 'b64_2 DIV 16')

I didn't time the base64.rc on a multi-KB attachment yet, but it 
is certainly good enough to use for classifying attachments, by 
decoding the first few lines of them, especially if you don't 
have other tools available.

-- 
Affijn, Ruud

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail