• 0

[VB.NET] File Encryption


Question

Hi All,

I'm trying to encrypt a file using TripleDES. However I've looked for samples all over the place and they all seem to be fairly unhelpful. Most of them generate a random key for you or will only let you do one string at a time etc which doesn't work for my situation.

The security doesn't have to be great, it's just an extra method to stop basic users from tampering with the data.

Could anyone point me to a decent example or something or that nature?

Regardz :)

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
Hi All,

I'm trying to encrypt a file using TripleDES. However I've looked for samples all over the place and they all seem to be fairly unhelpful. Most of them generate a random key for you or will only let you do one string at a time etc which doesn't work for my situation.

The security doesn't have to be great, it's just an extra method to stop basic users from tampering with the data.

Could anyone point me to a decent example or something or that nature?

Regardz :)

If security isn't an issue you could use something simple like Base64. That'd prevent most people from tampering with it. Either that or just create your own little encryption function which really isn't that hard (just get int values for each char and rotate through each letter of your pass code and add the integers together and if the value > 255 then subtract, etc, then convert to char again. Basically just do some simple math to the int values of each char to encrypt and reverse the process to decrypt). I learned how to do basic encryption in VB6 when I was like 14-15 years old (that's how easy it is).

Link to comment
Share on other sites

  • 0

Base64 is a quick and easy encoding method, and you can do it simply by:

Dim source As String = "Hello World"
Dim encoding As Encoding = Encoding.ASCII

Dim target As String = Convert.ToBase64String(Encoding.GetBytes(source))

And to go the other way:

Dim source As String = "(base 64 string here)"
Dim encoding As Encoding = Encoding.ASCII

Dim target As String = Encoding.GetString(Convert.FromBase64String(source))

As you can see its real easy to decode to, so if this is a problem for you, I'd look into .NETs cryptography support. Bing/Google is your friend.

Link to comment
Share on other sites

  • 0
You can also use MD5 or SHA1, very easy to implement.

Sure, if you don't want to decrypt the file. MD5 and SHA are one-way encryption techniques, which means that once the object is encrypted, its encrypted forever and you can't get it back. They're also known as Hashing Functions.

Link to comment
Share on other sites

  • 0

Apologies, I know that MD5 and SHA1 are one-way but I thought that was what the OP wanted, a quick way to encrypt. I must have missed the decrypt part. Sorry about the troubles mate.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.