Use SecureRandom.hex(), it's in stdlib for both 1.8.x and 1.9.x