Artifact Content
Not logged in

Artifact 2083fda849d66e3eb9b9004ce7660b54bc929b31:


\ init wurstkessel to be actually useful

: random-init ( -- )
    s" /dev/random" r/o open-file throw >r
    wurst-salt state# r@ read-file throw drop
    r> close-file throw ;

: read-wurstrng ( fd -- flag )  { fd }
    0. fd reposition-file throw
    wurst-salt state# fd read-file throw state# = >r
    state-init state# fd read-file throw state# = r> and
    fd close-file throw ;

: write-wurstrng ( -- )
    s" ~/.wurstrng" r/w create-file throw >r
    wurst-salt state# r@ write-file throw
    state-init state# r@ write-file throw
    r> close-file throw ;

: salt-init ( -- )
    s" ~/.wurstrng" r/o open-file IF  drop random-init
    ELSE  read-wurstrng  0= IF  random-init  THEN  THEN
    rng-step write-wurstrng ;

wurst-init
salt-init