Use urlsafe_base64 for random key generation

This fixes issue with random keys containing `+` characters, which get translated to spaces in the Rails controller.