aklomp / base64

Fast Base64 stream encoder/decoder in C99, with SIMD acceleration
BSD 2-Clause "Simplified" License
868 stars 162 forks source link

The test binary fails to decode some well-formed base64-encoded strings #8

Closed ghost closed 8 years ago

ghost commented 8 years ago
make
export j=""
for i in b a s e 6 4 t e s t; do
  j="$j$i"
  echo -n $j | /usr/bin/base64 | ./bin/base64 -d
  echo
done

Output:

b
ba
decoding error

base
base6
decoding error

base64t
base64te
decoding error

base64test
aklomp commented 8 years ago

That's because /usr/bin/base64 prints a trailing newline. Try this instead:

#!/bin/sh
export j=""
for i in b a s e 6 4 t e s t; do
  j="$j$i"
  echo -n $j | /usr/bin/base64 | tr -d "\n" | bin/base64 -d
  echo
done

Or /usr/bin/base64 -w0.