2010-05-19

Bash: getting GuardTime integrity code from Twitter

To get GuardTime integrity code from Twitter, you can use this one-liner:

wget http://api.twitter.com/1/statuses/user_timeline/guardtime.xml -qO - | \
egrep '(Integrity Code).+(May 2010)' | egrep '[2-7A-Z-]+' -ow


The result you'll get is

AAAAAA-CL5XSA-AALC66-FS6OQX-IJEEAV-YFWQQY-GVSQEG-6RHWNO-YVBAM6-KHORDF-URA5NU-YXCAFW


Here's how it works.

wget http://api.twitter.com/1/statuses/user_timeline/guardtime.xml -qO -


downloads latest messages in XML format (see doc). Output is redirected to `stdout`, no extra messages are printed. Tweets with integrity code have the following format:

${Base32-encoded-integrity-code} (Integrity Code for 15 ${month} ${year})


So

egrep '(Integrity Code).+(May 2010)'


extracts the desired tweet from all that XML rubbish we've got (replace `May 2010` with whatever value you need). Finally,

egrep '[2-7A-Z-]+' -ow


extracts a Base32-encoded integrity code from the tweet body so that only entire-word matches are printed.

Of course anyone is welcome to improve that using `sed`, `awk`, `perl` or whatever tools seem applicable.

GuardTime is currently publishing integrity codes once a month, and only codes starting from January 2010 are currently available via Twitter.

Note that Twitter timeline should not be considered a trusted source of GuardTime control publications; other ways of getting them should be used in mission-critical systems.

2 comments:

Anonymous said...

suka, u tebja est postojannyje 4itaqteli, obnovljaj blog. blja.

Juri Hudolejev said...

RSS же есть для постоянных читателей (:

Я в отпуске, пинаю хуи и учу Эрланг. Мне пока нечего сказать миру (: