C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto
or
C:\WINDOWS\system32\Microsoft\Protect or Crypto.
These are replaced by SID if DataProtectionScope.LocalMachine is replaced by DataProtectionScope.CurrentUser.
In theory, if data are moved away from the machine, there would no way to decrypt,
even DataProtectionScope.CurrentUser for the same user logged on to a different machine:
byte[] entropyBytes =null;// Encoding.Unicode.GetBytes("GMO");
byte[] pBytes;
private void button1_Click(object sender, EventArgs e)
{
string plainText = this.textBox1.Text;
byte[] plainBytes = Encoding.Unicode.GetBytes(plainText);
pBytes = ProtectedData.Protect(plainBytes, entropyBytes, DataProtectionScope.LocalMachine);
string ps = Convert.ToBase64String(pBytes);
this.textBox2.Text = ps;
}
private void button2_Click(object sender, EventArgs e)
{
byte[] upBytes = ProtectedData.Unprotect(pBytes, entropyBytes, DataProtectionScope.LocalMachine);
this.textBox3.Text = Encoding.Unicode.GetString(upBytes);
}
No comments:
Post a Comment