Sha256: c27d21b5056fa838c91da5397b8d12f05c314331626d2bb62e4c40a3c914963a
Contents?: true
Size: 553 Bytes
Versions: 3
Compression:
Stored size: 553 Bytes
Contents
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> /* it's really stupid that there isn't a syscall for this */ static int fd = -1; void randombytes(unsigned char *x,unsigned long long xlen) { int i; if (fd == -1) { for (;;) { fd = open("/dev/urandom",O_RDONLY); if (fd != -1) break; sleep(1); } } while (xlen > 0) { if (xlen < 1048576) i = xlen; else i = 1048576; i = read(fd,x,i); if (i < 1) { sleep(1); continue; } x += i; xlen -= i; } }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby_nacl-0.1.2 | ext/ruby_nacl/NaCl/randombytes/devurandom.c |
ruby_nacl-0.1.1 | ext/ruby_nacl/NaCl/randombytes/devurandom.c |
ruby_nacl-0.1.0 | ext/ruby_nacl/NaCl/randombytes/devurandom.c |