Quote:
Originally Posted by Dosatron01
Die anderen Codes werden auch noch gebraucht...
Sind 9-10 an der Zahl.
|
jo in dem punkt is er der profi nicht ich dennoch brauch ich zuerst von Virtuos die erlaubnis das er den hack anpassen darf... weil ich lass ihn ohne erlaubnis nicht einfach an Virtuos hack rum basteln
Zitat vom Kumpel: das hilft wenig ohne gscheide Kommentare im Code. SO versteht ja niemand was der da vorhat...
er meint Kommentare wie Beispiel von mir: Public Class frmCrypto
'Creates the Byte-Key which will be used in subEncryptOrDecryptFile
'The first 32 bytes of the Password-Hash will be used as the Key
'
'Input:
' strPassword The Passsword to encrypt
'Output:
' funCreateKey The Key to use in subEncryptOrDecryptFile
'
Private Function funCreateKey(ByVal strPassword As String) As Byte()
Try
'Convert strPassword to an array and store in chrData.
Dim chrData() As Char = strPassword.ToCharArray
'Use intLength to get strPassword size.
Dim intLength As Integer = chrData.GetUpperBound(0)
'Declare bytDataToHash and make it the same size as chrData.
Dim bytDataToHash(intLength) As Byte
'Use For Next to convert and store chrData into bytDataToHash.
For i As Integer = 0 To chrData.GetUpperBound(0)
bytDataToHash(i) = CByte(Asc(chrData(i)))
Next
'Declare what hash to use.
Dim SHA512 As New System.Security.Cryptography.SHA512Managed
'Declare bytResult, Hash bytDataToHash and store it in bytResult.
Dim bytResult As Byte() = SHA512.ComputeHash(bytDataToHash)
'Declare bytKey(31). It will hold 256 bits.
Dim bytKey(31) As Byte
'Use For Next to put a specific size (256 bits) of
'bytResult into bytKey. The 0 To 31 will put the first 256 bits
'of 512 bits into bytKey.
For i As Integer = 0 To 31
bytKey(i) = bytResult(i)
Next
Return bytKey 'Return the key.
Catch ex As Exception
'ERROR
End Try
End Function
'Creates the Byte-Initialization Vector which will be used in subEncryptOrDecryptFile
'The first Bytes 32 to 47 of the Password-Hash will be used as the IV
'
'Input:
' strPassword The Passsword to encrypt
'Output:
' funCreateIV The IV to use in subEncryptOrDecryptFile
'
Private Function funCreateIV(ByVal strPassword As String) As Byte()
Try
'Convert strPassword to an array and store in chrData.
Dim chrData() As Char = strPassword.ToCharArray
'Use intLength to get strPassword size.
Dim intLength As Integer = chrData.GetUpperBound(0)
'Declare bytDataToHash and make it the same size as chrData.
Dim bytDataToHash(intLength) As Byte
'Use For Next to convert and store chrData into bytDataToHash.
For i As Integer = 0 To chrData.GetUpperBound(0)
bytDataToHash(i) = CByte(Asc(chrData(i)))
Next
'Declare what hash to use.
Dim SHA512 As New System.Security.Cryptography.SHA512Managed
'Declare bytResult, Hash bytDataToHash and store it in bytResult.
Dim bytResult As Byte() = SHA512.ComputeHash(bytDataToHash)
'Declare bytIV(15). It will hold 128 bits.
Dim bytIV(15) As Byte
'Use For Next to put a specific size (128 bits) of bytResult into bytIV.
'The 0 To 30 for bytKey used the first 256 bits of the hashed password.
'The 32 To 47 will put the next 128 bits into bytIV.
For i As Integer = 32 To 47
bytIV(i - 32) = bytResult(i)
Next
Return bytIV 'Return the IV.
Catch ex As Exception
'ERROR
End Try
End Function