I’m trying to log into the VM using an encrypted password.
The password value is saved in and ini file, but the log in section is failing
to de-encrypt the password. I’m trying to use Unicode to perform the
enycryption. Here is what I have so far:
string
ans = ReadConfigValue(Section, Key);
if
(ans == null)
{
{size:10pt}{
{color:blue}return DefaultValue;
}
ans = ProtectValue(ans);
return ans;
}</span>
private string ReadConfigValue(string
Section, string Key)
int
i = GetPrivateProfileString(Section, Key, "",
temp, 512, this.configFilePath);
if (i == 0)
{
return null;
}
return temp.ToString();
}</span>
private string ProtectValue(string password)
byte[]
{
bytes = {color:#2b91af}Encoding.Unicode.GetBytes(password);
byte[]
protectedPassword = ProtectedData.Protect(bytes, null, DataProtectionScope.CurrentUser);
return Convert.ToBase64String(protectedPassword);
}</span>
virtualMachine.LoginInGuest(configValues.Username,
configValues.Password, configValues.Timeout);