orphaeus Δημοσ. 20 Φεβρουαρίου 2009 Δημοσ. 20 Φεβρουαρίου 2009 έχει ασχοληθεί κανένας με password encryption; προσπαθώ να βρω έτοιμες συναρτήσεις κωδικοποίησης για να τις χρησιμοποιήσω σε vb script/access αλλά είναι πιο δύσκολο απ' ότι νόμιζα. αν έχει κάποιος κάτι υπόψην του, θα το εκτιμούσα. ευχαριστώ.
ntaryl Δημοσ. 20 Φεβρουαρίου 2009 Δημοσ. 20 Φεβρουαρίου 2009 καλησπερα θα σου προτεινα να ψαξεις για το Aes, rc4 ***αυτόματη ένωση μηνυμάτων*** > '******************************************************************************* ' MODULE: FTestRijndael ' FILENAME: FTestRijndael.frm ' AUTHOR: Phil Fresle ' CREATED: 19-Feb-2001 ' COPYRIGHT: Copyright 2001 Phil Fresle ' EMAIL: [email protected] ' WEB: http://www.frez.co.uk ' ' DESCRIPTION: ' Tests out the Rijndael classes attached. Do not expect this to be blisteringly ' fast. Implement in C if you want speed. ' ' MODIFICATION HISTORY: ' 19-Feb-2001 Phil Fresle Initial Version ' 03-Apr-2001 Phil Fresle Also tests EncryptData and DecryptData functions '******************************************************************************* Option Explicit '******************************************************************************* ' cmdTest_Click (SUB) '******************************************************************************* Private Sub cmdTest_Click() Dim oRijndael As CRijndael Dim i As Long Dim nb As Long Dim nk As Long Dim KEY(31) As Byte Dim block(31) As Byte Dim sTemp As String Dim sResults As String Set oRijndael = New CRijndael oRijndael.gentables For i = 0 To 31 KEY(i) = 0 Next KEY(0) = 1 For i = 0 To 31 block(i) = i Next sResults = "" For nb = 4 To 8 Step 2 For nk = 4 To 8 Step 2 oRijndael.gkey nb, nk, KEY sResults = sResults & "Block Size=" & nb * 32 & ", Key size=" & nk * 32 & vbCrLf Debug.Print "Block Size=" & nb * 32 & ", Key size=" & nk * 32 sResults = sResults & "Plain" & vbCrLf Debug.Print "Plain" sTemp = "" For i = 0 To (nb * 4) - 1 sTemp = sTemp & Right("0" & Hex(block(i)), 2) Next Debug.Print sTemp sResults = sResults & sTemp & vbCrLf oRijndael.Encrypt block sResults = sResults & "Encrypt" & vbCrLf Debug.Print "encrypt" sTemp = "" For i = 0 To (nb * 4) - 1 sTemp = sTemp & Right("0" & Hex(block(i)), 2) Next Debug.Print sTemp sResults = sResults & sTemp & vbCrLf oRijndael.Decrypt block sTemp = "" Debug.Print "decrypt" sResults = sResults & "Decrypt" & vbCrLf For i = 0 To (nb * 4) - 1 sTemp = sTemp & Right("0" & Hex(block(i)), 2) Next Debug.Print sTemp sResults = sResults & sTemp & vbCrLf sResults = sResults & vbCrLf Next Next txtResults.Text = sResults End Sub '******************************************************************************* ' cmdTest2_Click (SUB) ' ' Tests out string input into Rijndael '******************************************************************************* Private Sub cmdTest2_Click() Dim oTest As CRijndael Dim sTemp As String Dim bytIn() As Byte Dim bytOut() As Byte Dim bytPassword() As Byte Dim bytClear() As Byte Dim lCount As Long Dim lLength As Long Set oTest = New CRijndael ' Do a quick and dirty conversion of message and password to byte arrays, as the ' string is Unicode we will get two bytes per character. You might want to loop through ' instead if you are only dealing in ASCII using the ASC() function so you get one ' byte per character. ' NOTE: You need to be very careful here if you are encrypting on a system ' with one character set and then expecting to decrypt on a different system ' with a different character set (e.g. Japanese to US English). It will not be ' a problem if you are only using the ASCII range 0-127, but remember, we are ' encrypting/decrypting bytes not characters, the byte encryption/decryption ' will be correct, but your conversion between bytes and characters needs to be ' tested out. bytIn = txtPlain.Text bytPassword = txtKey.Text ' This is the alternate way for single bytes... ' sTemp = txtPlain.Text ' lLength = Len(sTemp) ' ReDim bytIn(lLength - 1) ' For lCount = 1 To lLength ' bytIn(lCount - 1) = AscB(Mid(sTemp, lCount, 1)) ' Next ' sTemp = txtKey.Text ' lLength = Len(sTemp) ' ReDim bytPassword(lLength - 1) ' For lCount = 1 To lLength ' bytPassword(lCount - 1) = AscB(Mid(sTemp, lCount, 1)) ' Next ' Encrypt the data bytOut = oTest.EncryptData(bytIn, bytPassword) ' Display in hex or not If chkHex.Value = vbChecked Then sTemp = "" For lCount = 0 To UBound(bytOut) sTemp = sTemp & Right("0" & Hex(bytOut(lCount)), 2) Next txtEncrypted.Text = sTemp Else sTemp = bytOut ' Alternate way... ' lLength = UBound(bytOut) + 1 ' sTemp = String(lLength, " ") ' For lCount = 1 To lLength ' Mid(sTemp, lCount, 1) = Chr(bytOut(lCount - 1)) ' Next txtEncrypted.Text = sTemp End If ' NOTE: we are sending bytOut to be decrypted here. However, it is likely ' that we will need to reconstruct bytOut, say from the file it has been dumped ' in as a string. If it was dumped out in hex it can be reconstructed like this ' where sTemp is the string containing the encrypted data... If chkHex.Value = vbChecked Then lLength = Len(sTemp) ReDim bytOut((lLength \ 2) - 1) For lCount = 1 To lLength Step 2 bytOut(lCount \ 2) = CByte("&H" & Mid(sTemp, lCount, 2)) Next Else bytOut = sTemp ' Alternate way ' lLength = Len(sTemp) ' ReDim bytOut(lLength - 1) ' For lCount = 1 To lLength ' bytOut(lCount - 1) = AscB(Mid(sTemp, lCount, 1)) ' Next End If ' Decrypt bytClear = oTest.DecryptData(bytOut, bytPassword) ' Quick and dirty conversion back to a string. If we earlier looped using the ASC() function ' to get one byte per character, we will now need to do the opposite and loop using ' the CHR() function to put the string back together again. txtPlainAgain.Text = bytClear ' This is the alternate way for single bytes... ' lLength = UBound(bytClear) + 1 ' sTemp = String(lLength, " ") ' For lCount = 1 To lLength ' Mid(sTemp, lCount, 1) = Chr(bytClear(lCount - 1)) ' Next ' txtPlainAgain.Text = sTemp End Sub
orphaeus Δημοσ. 21 Φεβρουαρίου 2009 Μέλος Δημοσ. 21 Φεβρουαρίου 2009 ευχαριστώ ntaryl. βρήκα τον κώδικα για md5 encryption και μολις πριν λίγο διάβασα οτι έχει πολλές τρύπες. τώρα ψάχνω τον κώδικα για sha-1, sha-2, sha-256 encryption που διάβασα ότι δεν έχει τρύπες αλλά μόνο ψευδοκώδικα βρίσκω.
ippo00 Δημοσ. 21 Φεβρουαρίου 2009 Δημοσ. 21 Φεβρουαρίου 2009 μια χαρά είναι το md5 με salt. Πάντως και στα sha έχουν βρεί και προβλήματα. 'Ετοιμο κώδικα' για sha δεν έχω δει.. αλλά έτοιμα libs σίγουρα. (αν δεν βρείς θα σου φτιάξω εγώ) edit: sorry δεν είδα ότι είναι σε vb script(δεν τηα έγραφα code σ'αυτή τη γλώσσα). πάντως μην φοβάσαι to md5
Προτεινόμενες αναρτήσεις
Αρχειοθετημένο
Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.