Use SecureRandom.base64

(cherry picked from commit d965a60dc72b052da8624f4b86e35fc409fa49b5)