Encrypt and Decrypt File and Read it.
Post your questions regarding programming in C# in here.
6 posts
Page 1 of 1
How can i create a file ex (.dlx)*random extension*.
With encrypted data so the user can't open in a .txt file.
For example if someone opened it, it would look like this:
With encrypted data so the user can't open in a .txt file.
For example if someone opened it, it would look like this:
Code: Select all
ÃÑr&àùÃ3_#Ÿªž;K‘Ä6ÉxQåÍo¨úlµÔ}@["µ¾EäÇËà bÀ·Öð¨X›>9j=›ýÎñLð-{©–y»]Ù: à½_¼ûw˜è“ˆC}˜íU¬¡B
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

You could use IO.File.Encrypt, it ensures that only the user that encrypted it can open or decrypt it. You could also use the Cryptography namespace inside System.Security. Here is an example
To decrypt it use this:
Code: Select all
Just import System.Security.Cryptography first Dim Holder As New TripleDESCryptoServiceProvider 'There are many others too
Holder.Key = System.Text.Encoding.ASCII.GetBytes("Password") 'Either 8 or 16 to 24 characters
Holder.GenerateIV()
Dim Encrypter As ICryptoTransform = Holder.CreateEncryptor
Dim FileStream As New IO.FileStream("File Path", IO.FileMode.Open, IO.FileAccess.Read)
Dim FileData(FileStream.Length) As Byte
FileStream.Read(FileData, 0, FileStream.Length)
FileStream.Close()
Dim Encrypted As Byte() = Encrypter.TransformFinalBlock(FileData, 0, FileData.Length)
IO.File.WriteAllBytes("File Path", Encrypted)
Holder.Dispose()
Encrypter.Dispose()
To decrypt it use this:
Code: Select all
Oh dang... Its C#! Well wait a minute... :evil: Dim Holder As New TripleDESCryptoServiceProvider 'There are many others too
Holder.Key = System.Text.Encoding.ASCII.GetBytes("Password") 'Either 8 or 16 to 24 characters
Dim Decryptor As ICryptoTransform = Holder.CreateDecryptor
Dim FileStream As New IO.FileStream("File Path", IO.FileMode.Open, IO.FileAccess.Read)
Dim FileData(FileStream.Length) As Byte
FileStream.Read(FileData, 0, FileStream.Length)
FileStream.Close()
Dim Decrypted As Byte() = Decryptor.TransformFinalBlock(FileData, 0, FileData.Length)
IO.File.WriteAllBytes("File Path", Decrypted)
Holder.Dispose()
Decryptor.Dispose()
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

MrAksel wrote:You could use IO.File.Encrypt, it ensures that only the user that encrypted it can open or decrypt it. You could also use the Cryptography namespace inside System.Security. Here is an exampleI'll try and convert itCode: Select allJust import System.Security.Cryptography firstDim Holder As New TripleDESCryptoServiceProvider 'There are many others too Holder.Key = System.Text.Encoding.ASCII.GetBytes("Password") 'Either 8 or 16 to 24 characters Holder.GenerateIV() Dim Encrypter As ICryptoTransform = Holder.CreateEncryptor Dim FileStream As New IO.FileStream("File Path", IO.FileMode.Open, IO.FileAccess.Read) Dim FileData(FileStream.Length) As Byte FileStream.Read(FileData, 0, FileStream.Length) FileStream.Close() Dim Encrypted As Byte() = Encrypter.TransformFinalBlock(FileData, 0, FileData.Length) IO.File.WriteAllBytes("File Path", Encrypted) Holder.Dispose() Encrypter.Dispose()
To decrypt it use this:Code: Select allOh dang... Its C#! Well wait a minute... :evil:Dim Holder As New TripleDESCryptoServiceProvider 'There are many others too Holder.Key = System.Text.Encoding.ASCII.GetBytes("Password") 'Either 8 or 16 to 24 characters Dim Decryptor As ICryptoTransform = Holder.CreateDecryptor Dim FileStream As New IO.FileStream("File Path", IO.FileMode.Open, IO.FileAccess.Read) Dim FileData(FileStream.Length) As Byte FileStream.Read(FileData, 0, FileStream.Length) FileStream.Close() Dim Decrypted As Byte() = Decryptor.TransformFinalBlock(FileData, 0, FileData.Length) IO.File.WriteAllBytes("File Path", Decrypted) Holder.Dispose() Decryptor.Dispose()

Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

I cant finish it now, but im nearly done with an example app
Edit, Here it is: Its a command line app. If you want to encrypt a file, add this to the startup commands encrypt "FILENAME" Filename inside the quotes.
To decrypt just change encrypt to decrypt
Edit, Here it is: Its a command line app. If you want to encrypt a file, add this to the startup commands encrypt "FILENAME" Filename inside the quotes.
To decrypt just change encrypt to decrypt
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

Zach, you got it? I got a nice command line app for you.
You can now encrypt multiple files at the same time. Just add those arguments
encrypt (or decrypt) "File1" "File2" "File3" Just separate the file names with spaces and put them in quotes.
You can now encrypt multiple files at the same time. Just add those arguments
encrypt (or decrypt) "File1" "File2" "File3" Just separate the file names with spaces and put them in quotes.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

MrAksel wrote:Zach, you got it? I got a nice command line app for you.Im going to be using the decrypt and encrypt for a game. the file will be the dlc information being read
You can now encrypt multiple files at the same time. Just add those arguments
encrypt (or decrypt) "File1" "File2" "File3" Just separate the file names with spaces and put them in quotes.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023