rewrite getrandom to csh