简体   繁体   中英

Encrypt a file without a password VB.NET

I have had a look on this and other websites but couldn't find anything that exactly matches what I need. What I need is a method of encrypting (or obfuscating) a file (not an exe) without the need for the user to input a password this is because I nee a separate program possibly running on another computer with no connection to the encrypting machine to be able to read the file. However if someone reads the file in between the two terminals it will look like gibberish and will be hopefully very hard to decrypt. I currently have a basic caesar shift type encryption. I understand that this will rely on some level of security through obscurity however any ideas would be very welcome. Thanks in advance!!

The type of encryption that you are describing, where the same known "password" (key) must be known on both ends is called symmetric encryption . Symmetric encryption can be performed in .NET by using any one of the encryption provider classes which inherit from the SymmetricAlgorithm base class, such as AesCryptoServiceProvider .

If you don't want both ends to have to know the same password, the most common solution is to use something called asymmetric encryption . With asymmetric encryption, there is a publicly view-able key (anyone can see it), but that key is only useful for encrypting data. There is no reasonable way to decrypt data when all you know is the public key. Therefore, the recipient can generate the public key and send it, in plain text, to the sender. The sender can then encrypt the message, using that public key and safely send it to the recipient. The recipient, then, can decode the data using it's private key. Only the recipient knows the private key that was used to generate the public key. This is the form of encryption used on the internet for making secure websites.

The down-side to asymmetric encryption is that the sender and receiver need to have live two-way communication to make it practical. It is also only useful if there is only one recipient which needs to be able to decode the data.

Asymmetric encryption can be performed in .NET by using any one of the provider classes which inherit from the AsymmetricAlgorithm base class, such as the RSACryptoServiceProvider class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM