• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Saving to registry question using C#

Status
Not open for further replies.
Level 29
Joined
Oct 24, 2012
Messages
6,543
I have a function that successfully creates protected passwords and other encryption keys and IV.

My question is how are passwords saved when using a server to run the program.
Does it save the encrypted passwords in the registry of the server or does it save it to the device that saves the encryption to the registry ( the pc running the program) ?
I'm thinking it saves it to the registry of the server but i just want to make sure.

Thanks for any help.
 
So you have a server and a client or is your app only one program? I'm a bit confused on what you're asking or what you mean by "registry of the server".

If you're trying to save data from clients on a server, I would use encrypted files or SQL. You don't want the clients to have any control over the data which is saved, so keep the data on the server. Although, if what you mean was "where do I store user information for people that use my program", then registry is alright, but I would personally store it in a file.

Sorry if I misunderstood.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Sorry to confuse lol.
I have a program i made that runs off of a server. Each pc can run program if they are connected to the server.
I made a login form that requires a username and a password.
I then encrypt that password like this.

Code:
        private string Encrypt(string Key, string IV, string encryptPass) // Key must be 32 in length. IV must be 16 in length.
        {
            byte[] plaintextbytes = System.Text.ASCIIEncoding.ASCII.GetBytes(encryptPass);
            AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
            aes.BlockSize = 128;
            aes.KeySize = 256;
            aes.Key = System.Text.ASCIIEncoding.ASCII.GetBytes(Key);
            aes.IV = System.Text.ASCIIEncoding.ASCII.GetBytes(IV);
            aes.Padding = PaddingMode.PKCS7;
            aes.Mode = CipherMode.CBC;
            ICryptoTransform crypto = aes.CreateEncryptor(aes.Key, aes.IV);
            byte[] encrypted = crypto.TransformFinalBlock(plaintextbytes, 0, plaintextbytes.Length);
            crypto.Dispose();
            return Convert.ToBase64String(encrypted);
        }
I then take the returned encrypted password and save it to the registry.
I decrypt using the KEY and IV basically the same way.
My question is if the program is run on another pc does the registry get saved to the pc using the program or in the server registry ?

Sorry i forgot to post how i save to the registry lol.

Here is the code to save to the registry.
Code:
        private void savePass( string encrypted)
        {
            RegistryKey rKey = Registry.CurrentUser.CreateSubKey("Encryptor");
            rKey.SetValue("Password", encrypted);
        }
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Windows Registry or some type of server registry?

If it's being stored in the PCs local registry, then it will stay local and not carry over.
If it's being stored on the server, then it may be carried over. It all depends on how the server handles things.

You didn't create the server?

I'm using a computer as a server. I didn't make a specific server program for this program as it wasn't necessary. I'm using the network as a way to run the program from all the other pcs on that network. Only the server needs the program to be installed this way and it keeps all the information on the server. I'm just not sure how saving to the registry works when using the pc as a server in this method.
 
deathismyfriend said:
Here is the code to save to the registry.

Ah, wasn't there when I posted.

deathismyfriend said:
I'm using a computer as a server. I didn't make a specific server program for this program as it wasn't necessary. I'm using the network as a way to run the program from all the other pcs on that network. Only the server needs the program to be installed this way and it keeps all the information on the server.

Yes but the computer is running a server program, correct? How else would it communicate with your app.

deathismyfriend said:
I'm just not sure how saving to the registry works when using the pc as a server in this method.

Well, there's no way to tell from the code you've posted but there could be a few reasons why the registry is being used.
  • The registry key is being added to the server, not the client.
  • It's simply being saved on clientside so you don't have to type the password twice.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Well, there's no way to tell from the code you've posted but there could be a few reasons why the registry is being used.
  • The registry key is being added to the server, not the client.
  • It's simply being saved on clientside so you don't have to type the password twice.

I'm using the registry to save the passwords to. Rather than saving them to a specific file it creates them in the registry. I'm just not sure if it creates the registry file on the client pc or on the server pc. I don't know if the code provided is all the code i need to save to the server or if i need more code to make sure it saves it to the registry of the server pc.

To provide some insight on the program.
Also this program is XML file based so it doesn't need to sync data. It opens and loads data then closes the xml file/s when necessary. I know if a lot of pcs are accessing the xml file at once that it will cause error. But in my testing i had to click on the button that loads that file at almost the exact same time. It took me about 40 clicks to get one error so it is low enough for this type of program. If it becomes necessary ill write an Asynchronous server for this program.

I am very new to registry only messed with it in the past few hrs.
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
I'm pretty sure the clients can't access the registry of the server, so it will stay on the client. But you could test it with another computer, and that would solve many things.

Point is, as far as I know you can't access system files and the registry of the server like this, you need a separate server program that runs on the server (so it has the authority of the server admin, rather than the client authority), receives the data from the clients and saves it. Even if it worked otherwise, that would mean the clients have direct access to the server's system files (since your program actually runs on the client), and that's not a nice way to do it.
 
Status
Not open for further replies.
Top