coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Faster base64 -d


From: Ole Tange
Subject: Faster base64 -d
Date: Mon, 8 Apr 2013 04:35:54 +0630

I was astonished to learn that:

  perl -MMIME::Base64 -e 'while(read(STDIN,$buf,770*50)){print
decode_base64($buf)}'

is faster than:

  base64 -d

I found this which might be faster:
http://www.experts-exchange.com/Programming/System/Windows__Programming/A_3216-Fast-Base64-Encode-and-Decode.html

I would reckon this would be even faster for decoding:

      WORD s1= gpLookup16[ pwSrc[0] ];  // translate two "digits" at once
      WORD s2= gpLookup16[ pwSrc[1] ];  // ... and two more

      // s1 = xx111111 222222xx
      // s2 = xx333333 444444xx
      pDst[0]= (s1 >> 6 & 0xff); // xxxxxxxx 11111122
      pDst[1]= (s1 << 2 & 0xf0 | s2 >> 10 & 0x0f); // xxxxxxxx 22223333
      pDst[2]= (s1 >> 2 & 0xff); // xxxxxxxx 33444444

I am interested in having 'base64 -d' faster since next version of GNU
Parallel may use Base64 as a transport mode of large amounts of data.


/Ole



reply via email to

[Prev in Thread] Current Thread [Next in Thread]