use stdlib prng
fix accidentally removed sizeof
proper type conversion
use unsigned char