Hacker News new | past | comments | ask | show | jobs | submit login

A funny thing about Base64: if you iterate encoding starting from any string, a growing prefix of the result tends towards a fixed point. In Bash:

    $ function iter {
    N="$1"
    CMD="$2"
    STATE=$(cat)
    for i in $(seq 1 $N); do
       STATE=$(echo -n $STATE | $CMD)
    done
    cat <<EOF
    $STATE
    EOF
    }
    $ echo "HN" | iter 20 base64 | head -1
    Vm0wd2QyUXlVWGxWV0d4V1YwZDRWMVl3WkRSV01WbDNXa1JTVjAxV2JETlhhMUpUVmpBeFYySkVU
    $ echo "Hello Hacker News" | iter 20 base64 | head -1
    Vm0wd2QyUXlVWGxWV0d4V1YwZDRWMVl3WkRSV01WbDNXa1JTVjAxV2JETlhhMUpUVmpBeFYySkVU
    $ echo "Bonjour Hacker News" | iter 20 base64 | head -1
    Vm0wd2QyUXlVWGxWV0d4V1YwZDRWMVl3WkRSV01WbDNXa1JTVjAxV2JETlhhMUpUVmpBeFYySkVU
EDIT: I just remembered that when I found that out by pure serendipity more than 10 years ago I tweeted cryptically about it [1] and someone made a blog post on the subject which I submitted here but it didn't generate discussion [2]. Someone else posted it on Reddit /r/compsci and it generated fruitful discussion there, correcting the blog post [3]. The blog is down now but the internet archive has a copy of it [4].

[1] https://twitter.com/p4bl0/status/298900842076045312

[2] https://news.ycombinator.com/item?id=5181256

[3] https://www.reddit.com/r/compsci/comments/18234a/the_base64_...

[4] https://web.archive.org/web/20130315082932/http://fmota.eu/b...




Whoa, that's really neat!


Aww the article linked in Reddit is dead


As explained in my comment above, the blog is dead, but link 4 in my comment is a backup of this article by archive.org.


Oops missed that




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: