Random droppings By hand using for powers of 2: Math::BigInt->new('0x' . unpack('H*', random_bytes($n)));