Codegolf/wpa

From NoName e.V.
Revision as of 01:23, 15 February 2013 by Merovius (talk | contribs) (Angelegt)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Die Problemstellung: Erzeuge (ggf. mit einem von stdin entgegengenommenem stream von random-bytes) eine WPA-Passphrase, d.h. 63 Zeichen printable ASCII.

Nur die kürzesten Lösungen:

C

main(c,i){i=63;while(i)putchar(isprint(c=getchar())?(--i,c):0);}

(Merovius)

"Pure" Perl

perl -ne'/[ -~]/&&($i+=print$&)>63&&die' < /dev/urandom

(mxf)

Perl

perl -ne'y/ -~//cd;print'</dev/urandom|head -c63

(sECuRE)

Shell

</dev/urandom tr -dc [-~] | head -c64

(koebi)

Dann gekürzt zu:

tr -dc \ -~</*/ur*|head -c63

(mxf, sECuRE und Merovius)

Haskell

import Data.Char
fkt = do
 c <- getChar
 if (((ord c) >= 33) && ((ord c) <= 126))
 then putChar c
 else return()
 fkt
main = do fkt

(joker)