diff options
| author | ShiftOS <[email protected]> | 2015-03-07 22:31:31 +0200 |
|---|---|---|
| committer | ShiftOS <[email protected]> | 2015-03-07 22:31:31 +0200 |
| commit | 4caacce50cef00e4175d35f78f2089f1f6d69562 (patch) | |
| tree | 6b1ceb79d9590869fe3742753e68831378cc9e56 /File_Crypt.vb | |
| parent | feafdde01c360f8260b4092fc045952d97ad8872 (diff) | |
| download | shiftos-4caacce50cef00e4175d35f78f2089f1f6d69562.tar.gz shiftos-4caacce50cef00e4175d35f78f2089f1f6d69562.tar.bz2 shiftos-4caacce50cef00e4175d35f78f2089f1f6d69562.zip | |
ShiftOS
ShiftOS is a game about evolving an experimental operating system called
"ShiftOS" from a completely black and white text based command line
based OS to a fully graphical operating system filled with advanced
features and beautiful colours. The level of customization will exceed
the levels of real world operating systems
Diffstat (limited to 'File_Crypt.vb')
| -rw-r--r-- | File_Crypt.vb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/File_Crypt.vb b/File_Crypt.vb new file mode 100644 index 0000000..d6ee0f7 --- /dev/null +++ b/File_Crypt.vb @@ -0,0 +1,55 @@ +Imports System +Imports System.IO +Imports System.Security +Imports System.Security.Cryptography +Imports System.Text +Public Class File_Crypt + Public Const sSecretKey As String = "Password" + + Public Shared Sub EncryptFile(ByVal sInputFilename As String, ByVal sOutputFilename As String, ByVal sKey As String) + + Dim fsInput As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read) + Dim fsEncrypted As New FileStream(sOutputFilename, FileMode.Create, FileAccess.Write) + + Dim DES As New DESCryptoServiceProvider() + + + DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey) + + DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey) + + Dim desencrypt As ICryptoTransform = DES.CreateEncryptor() + + Dim cryptostream As New CryptoStream(fsEncrypted, desencrypt, CryptoStreamMode.Write) + + Dim bytearrayinput(fsInput.Length - 1) As Byte + fsInput.Read(bytearrayinput, 0, bytearrayinput.Length) + cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length) + cryptostream.Dispose() + fsInput.Dispose() + fsEncrypted.Dispose() + End Sub + + Public Shared Sub DecryptFile(ByVal sInputFilename As String, ByVal sOutputFilename As String, ByVal sKey As String) + + Dim DES As New DESCryptoServiceProvider() + + + DES.Key() = ASCIIEncoding.ASCII.GetBytes(sKey) + + DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey) + + Dim fsread As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read) + + Dim desdecrypt As ICryptoTransform = DES.CreateDecryptor() + + Dim cryptostreamDecr As New CryptoStream(fsread, desdecrypt, CryptoStreamMode.Read) + + Dim fsDecrypted As New StreamWriter(sOutputFilename) + fsDecrypted.Write(New StreamReader(cryptostreamDecr).ReadToEnd) + fsDecrypted.Flush() + fsread.Dispose() + fsDecrypted.Dispose() + End Sub + +End Class
\ No newline at end of file |
