| |
VB.NET - Ein- und UmsteigerDaten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 11.10.06 15:19 |
| Hi, also ich habe einen code gefunden (http://support.microsoft.com/kb/301070/de) um dateien zu verschlüsseln. was muss ich ändern, damit auch umlaute gelesen werden?
Z.b. kann ich damit keine bilder oder so verschlüsseln(entschlüsseln). | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: SystemX | Datum: 11.10.06 15:23 |
| "The Page you requested is not available" | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 11.10.06 15:25 |
| bei mir gehtse
denk dadrann das du die mit dem ie öffnen musst da sonst alles falsch dargestellt is | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: SystemX | Datum: 11.10.06 15:29 |
| Stimmt, wenn ich das /de dahinter weglasse gehts | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 11.10.06 15:36 |
| du meinst so?
[CODE] Dim fsDecrypted As New StreamWriter(sOutputFilename, False, System.Text.Encoding.Default)[/CODE]
da passiert nix... | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 11.10.06 17:02 |
| jez gehts danke | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 29.10.06 14:39 |
| so da ich nun problemlos dateien verschlüsseln kann: wie mach ich das nun das ich ordner verschlüsseln kann? also ich kann zwar jede datei einzeln verschlüsseln, aber den inhalt kann man dann ja immer noch sehen. kann man vielleicht den code umschreiben, das das auch mit ordnern geht? oder den ordner in eine rar datei mit passwort packt? danke schonmal | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: MeikMiller | Datum: 29.10.06 18:34 |
| Es gibt auch die andere Methoden die das Ermöglichen. | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: MeikMiller | Datum: 29.10.06 18:43 |
| ich kenne Methode die ermöglichen Verschießen Dateien, Ordnern, RichTextBox-Inhalt, TextBox-Inhalt, aber hat eine aber fehlerhaft mit dateien unter 8bit. Wenn jemand Interessiert kann ich auch posten (hat lange Classe)... | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 29.10.06 19:49 |
| ja ich denke mich.. aber was ist verschießen? oder was meinste damit? und "aber hat eine aber fehlerhaft " ? könntest du das nochmal deutlich schreiben? danke | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 29.10.06 20:07 |
| aso ja ok schreib mal den code nur für die ordner, bitte | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: MeikMiller | Datum: 29.10.06 20:10 |
| Bitte schon:
Weil die Classe ist zu lang teile ich dieses:
Teil1:
Imports System.IO
Imports System.Text
Imports System.Security.Cryptography
Imports System.Runtime.InteropServices
Public Class clsDES : Inherits ApplicationException
Private mKey As String
Private Vector() As Byte = {&H12, &H44, &H16, &HEE, &H88, &H15, &HDD, &H41}
Private TheKey(7) As Byte
Private objDES As New DESCryptoServiceProvider
Public Property Key() As String
Get
Return mKey
End Get
Set(ByVal strKey As String)
Dim arrKeyBuffer(32767) As Byte
Dim AscEncod As New ASCIIEncoding
Dim i As Integer = 0
Try
mKey = strKey
AscEncod.GetBytes(strKey, i, strKey.Length, arrKeyBuffer, i)
Catch ex As Exception
Throw New ApplicationException("Key Conversion Error.")
End Try
Try
Dim hashSha As New SHA1CryptoServiceProvider
Dim arrHash() As Byte = hashSha.ComputeHash(arrKeyBuffer)
For i = 0 To 7
TheKey(i) = arrHash(i)
Next i
Catch ex As Exception
Throw New ApplicationException("Hashing Key Error.")
End Try
End Set
End Property mfgMeik MillerMein beste Code:If then | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: MeikMiller | Datum: 29.10.06 20:12 |
| Public Sub FolderEncrypt(ByVal InitialPath As String, ByVal Recursion As _
Boolean, ByVal DeleteSourceFile As Boolean)
Dim x As Long
If Recursion = True Then
FillRecursiveArray(InitialPath)
Else
FillNonRecursiveArray(InitialPath)
End If
For x = 1 To arrFiles.Length - 1 Step 1
FileEncrypt(arrFiles(CInt(x)), arrFiles(CInt(x)) & ".CRP", True)
Next
Try
If DeleteSourceFile = True Then
For x = 1 To arrFiles.Length - 1 Step 1
System.IO.File.Delete(arrFiles(CInt(x)))
Next
End If
Catch
Throw New ApplicationException("Error, can't delete uncrypted" & _
"files.")
End Try
End Sub
Public Sub FolderDecrypt(ByVal InitialPath As String, ByVal Recursion As _
Boolean, ByVal DeleteSourceFile As Boolean)
Dim x As Long
If Recursion = True Then
FillRecursiveArray(InitialPath)
Else
FillNonRecursiveArray(InitialPath)
End If
For x = 1 To arrFiles.Length - 1 Step 1
FileDecrypt(arrFiles(CInt(x)), Microsoft.VisualBasic.Left(arrFiles( _
CInt(x)), arrFiles(CInt(x)).Length - 3), True)
Next
Try
If DeleteSourceFile = True Then
For x = 1 To arrFiles.Length - 1 Step 1
System.IO.File.Delete(arrFiles(CInt(x)))
Next
End If
Catch
Throw New ApplicationException("Error, can't delete crypted files.")
End Try
End Sub mfgMeik MillerMein beste Code:If then | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: MeikMiller | Datum: 29.10.06 20:13 |
| Public Sub FileEncrypt(ByVal inName As String, ByVal outName As String, ByVal _
DeleteSourceFile As Boolean)
Dim bufPacket(4096) As Byte 'Create packet separator buffer (4096
' Byte / Packet)
Dim totalBytesWritten As Long = 8 'Written Bytes Cmptr
Dim packageSize As Integer 'Set number of byte to be write at same
' time
Try
Dim fIn As New FileStream(inName, FileMode.Open, FileAccess.Read)
Dim fOut As New FileStream(outName, _
FileMode.OpenOrCreate, FileAccess.Write)
Try
fOut.SetLength(0)
Dim totalFileLength As Long = fIn.Length 'Set Source File
' Size
Dim crStream As New CryptoStream(fOut, _
objDES.CreateEncryptor(TheKey, Vector), _
CryptoStreamMode.Write)
While totalBytesWritten < totalFileLength
packageSize = fIn.Read(bufPacket, 0, 4096)
crStream.Write(bufPacket, 0, packageSize)
totalBytesWritten = Convert.ToInt32(totalBytesWritten + _
packageSize / objDES.BlockSize * objDES.BlockSize)
End While
crStream.Close()
fIn.Close()
fOut.Close()
If DeleteSourceFile = True Then
System.IO.File.Delete(inName)
End If
Catch ex As Exception
Throw New ApplicationException(ex.Message)
fIn.Close()
fOut.Close()
End Try
Catch ex As Exception
Throw New ApplicationException("Input and/or Output File are" & _
"invalid.")
End Try
End Sub
Public Sub FileDecrypt(ByVal inName As String, ByVal outName As String, _
ByVal DeleteSourceFile As Boolean)
Dim bufPacket(4096) As Byte 'Create packet separator buffer (4096
' Byte / Packet)
Dim totalBytesWritten As Long = 8 'Written Bytes Cmptr
Dim packageSize As Integer 'Set number of byte to be write at same
' time
Try
Dim fIn As New FileStream(inName, FileMode.Open, FileAccess.Read)
Dim fOut As New FileStream(outName, _
FileMode.OpenOrCreate, FileAccess.Write)
Try
fOut.SetLength(0)
Dim totalFileLength As Long = fIn.Length 'Input File Size
Dim crStream As New CryptoStream(fOut, _
objDES.CreateDecryptor(TheKey, Vector), _
CryptoStreamMode.Write)
While totalBytesWritten < totalFileLength
packageSize = fIn.Read(bufPacket, 0, 4096)
crStream.Write(bufPacket, 0, packageSize)
totalBytesWritten = Convert.ToInt32(totalBytesWritten + _
packageSize / objDES.BlockSize * objDES.BlockSize)
End While
fIn.Close()
fOut.Close()
If DeleteSourceFile = True Then
System.IO.File.Delete(inName)
End If
Catch ex As Exception
Throw New ApplicationException(ex.Message)
fIn.Close()
fOut.Close()
End Try
Catch ex As Exception
Throw New ApplicationException("Input and/or Output File are" & _
"invalid.")
End Try
End Sub mfgMeik MillerMein beste Code:If then | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: MeikMiller | Datum: 29.10.06 20:14 |
| Public Function StringEncrypt(ByVal strSource As String) As String
Dim memStream As New MemoryStream 'Create memory stream to hold
' encrypted string
Try
Dim bufSource() As Byte = Encoding.UTF8.GetBytes(strSource)
Dim crStream As New CryptoStream(memStream, objDES.CreateEncryptor( _
TheKey, Vector), CryptoStreamMode.Write)
crStream.Write(bufSource, 0, bufSource.Length)
crStream.FlushFinalBlock()
Return Convert.ToBase64String(memStream.ToArray())
Catch ex As Exception
Throw New ApplicationException("String encryption Error.")
End Try
End Function
Public Function StringDecrypt(ByVal strSource As String) As String
Dim memStream As New MemoryStream 'Create memory stream to hold
' decypted string
Dim objDecode As System.Text.Encoding = System.Text.Encoding.UTF8 '
' Memory Decode Object
Try
Dim bufSource() As Byte = Convert.FromBase64String(strSource)
Dim crStream As New CryptoStream(memStream, objDES.CreateDecryptor( _
TheKey, Vector), CryptoStreamMode.Write)
crStream.Write(bufSource, 0, bufSource.Length)
crStream.FlushFinalBlock()
Return objDecode.GetString(memStream.ToArray())
Catch ex As Exception
Throw New ApplicationException("String decryption Error.")
End Try
End Function Private arrFiles() As String
Private Function GetFileContents(ByVal FullPath As String) As String
Dim strContents As String
Dim objReader As StreamReader
Try
objReader = New StreamReader(FullPath)
strContents = objReader.ReadToEnd()
objReader.Close()
Return strContents
Catch Ex As Exception
Throw New ApplicationException("Read Input File Error.")
End Try
End Function
Private Function SaveTextToFile(ByVal strData As String, ByVal FullPath As _
String) As Boolean
Dim bAns As Boolean = False
Dim objReader As StreamWriter
Try
objReader = New StreamWriter(FullPath)
objReader.Write(strData)
objReader.Close()
bAns = True
Catch Ex As Exception
Throw New ApplicationException("Write Ouput File Error.")
End Try
Return bAns
End Function mfgMeik MillerMein beste Code:If then | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 30.10.06 16:49 |
| und was genau macht der code? weden da nur alle dateien aus einem ordner verschlüsselt? oder wird der ordner so wie z.b. eine rar datei angezeigt, also so wie ich es wollte nur halt ohne die endung rar? | |
Re: Daten verschlüsseln - code ändern! (Wichtig!) | | | Autor: Knight | Datum: 30.10.06 18:14 |
| ja das hatte ich ja auch schon... ich wollte ja das man den ganzen ordner verschlüsselt. also alle dateien in einer zip datei zusammen fassen und die mit passwort schützen. ginge das vielleicht irgendwie? | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
vb@rchiv CD Vol.6 vb@rchiv Vol.6
Geballtes Wissen aus mehr als 8 Jahren vb@rchiv!
Online-Update-Funktion Entwickler-Vollversionen u.v.m.Jetzt zugreifen Tipp des Monats Neu! sevDTA 3.0 Pro
SEPA mit Kontonummernprüfung
Erstellen von SEPA-Dateien mit integriertem BIC-Verzeichnis und Konto- nummern-Prüfverfahren, so dass ungültige Bankdaten bereits im Vorfeld ermittelt werden können. Weitere Infos
|