Newbie to security -- I'm stuck.
From: Rob (Rob_at_discussions.microsoft.com)
Date: 10/15/04
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: How to get hashed password of current user"
- Next in thread: Nicole Calinoiu: "Re: Newbie to security -- I'm stuck."
- Reply: Nicole Calinoiu: "Re: Newbie to security -- I'm stuck."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 15 Oct 2004 13:55:17 -0700
This should be simple, but I can't seem to figure this out. I have a Windows
Service application and a GUI to interface to it. The service logs data to a
SQL Server database. I have the Login and Password for the database in the
Registry and I wish to encrypt it. The service retrieves the Login and
Password from the registry and the GUI sets the Login and Password to the
registry.
The GUI can set the encrypted Login and Password to the registry and can
read the encrypted Login and Password from the registry and display them.
There is no problem here. But the service using the same Key Container Name
as the GUI cannot decrypt the Login or Password and returns a "Bad Data"
exception.
Can anyone explain what I have done wrong? Any help is appreciated! Here
is a snippet of my code:
To read from the Registry -
Dim cp As New CspParameters
cp.KeyContainerName = _KEYCONTAINERNAME
Dim rsa As New RSACryptoServiceProvider(cp)
Login = Convert.ToBase64String(rsa.Decrypt(CType(GetRegistryValue("Login"),
Byte()), False))
Password =
Convert.ToBase64String(rsa.Decrypt(CType(GetRegistryValue("Password"),
Byte()), False))
To write to the Registry -
Dim cp As New CspParameters
cp.KeyContainerName = _KEYCONTAINERNAME
Dim rsa As New RSACryptoServiceProvider(cp)
SetRegistryValue("Login",
rsa.Encrypt(Convert.FromBase64String(txtLogin.Text), False))
SetRegistryValue("Password",
rsa.Encrypt(Convert.FromBase64String(txtPassword.Text), False))
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: How to get hashed password of current user"
- Next in thread: Nicole Calinoiu: "Re: Newbie to security -- I'm stuck."
- Reply: Nicole Calinoiu: "Re: Newbie to security -- I'm stuck."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|