private static DeviceUserName GenerateDeviceUserName()
        {
            var userName = new DeviceUserName();

            userName.DeviceName        = GenerateRandomString(LiveIdConstants.ValidDeviceNameCharacters, MaxDeviceNameLength);
            userName.DecryptedPassword = GenerateRandomString(LiveIdConstants.ValidDevicePasswordCharacters,
                                                              MaxDevicePasswordLength);

            return(userName);
        }
        private static LiveDevice GenerateDevice(string deviceName, string devicePassword)
        {
            // If the deviceName hasn't been specified, it should be generated using random characters.
            DeviceUserName userNameCredentials;

            if (string.IsNullOrEmpty(deviceName))
            {
                userNameCredentials = GenerateDeviceUserName();
            }
            else
            {
                userNameCredentials = new DeviceUserName {
                    DeviceName = deviceName, DecryptedPassword = devicePassword
                };
            }

            return(new LiveDevice {
                User = userNameCredentials, Version = 1
            });
        }