string crypt / decrypt - porting a vb.net class in vb6
$30-250 USD
Käynnissä
Julkaistu lähes 12 vuotta sitten
$30-250 USD
Maksettu toimituksen yhteydessä
good morning
I have a class written in vb .net that encrypt and decrypt strings. I need this to port in vb6, possibly without using external control or with ebcrypt encryption libray ([login to view URL])
here is the class
========================
Imports [login to view URL]
Public Class Simple3Des
Private TripleDes As New TripleDESCryptoServiceProvider
Private Function TruncateHash(ByVal key As String, ByVal length As Integer) As Byte()
Dim sha1 As New SHA1CryptoServiceProvider
Dim keyBytes() As Byte = [login to view URL](key)
Dim hash() As Byte = [login to view URL](keyBytes)
ReDim Preserve hash(length - 1)
Return hash
End Function
Sub New(ByVal key As String)
[login to view URL] = TruncateHash(key, [login to view URL] \ 8)
[login to view URL] = TruncateHash("", [login to view URL] \ 8)
End Sub
Public Function EncryptData(ByVal plaintext As String) As String
Dim Data As String = ""
Try
Dim plaintextBytes() As Byte = [login to view URL](plaintext)
Dim ms As New [login to view URL]
Dim encStream As New CryptoStream(ms, [login to view URL](), [login to view URL])
[login to view URL](plaintextBytes, 0, [login to view URL])
[login to view URL]()
Data = [login to view URL]([login to view URL])
Catch ex As Exception
Return Data
End Try
Return Data
End Function
Public Function DecryptData(ByVal encryptedtext As String) As String
Dim Data As String = ""
Try
Dim encryptedBytes() As Byte =
[login to view URL](encryptedtext)
Dim ms As New [login to view URL]
Dim decStream As New CryptoStream(ms, [login to view URL](), [login to view URL])
[login to view URL](encryptedBytes, 0, [login to view URL])
[login to view URL]()
Data = [login to view URL]([login to view URL])
Catch ex As Exception
Return Data
End Try
Return Data
End Function
' and hash function;
Private Shared Function Generatehash(ByVal SourceText As String, ByVal Full As Boolean) As String
Dim MyMD5CryptoServiceProvider As New MD5CryptoServiceProvider
Dim j As Integer = IIf(Full, 15, 7)
Dim bs As Byte() =
[login to view URL]([login to view URL](SourceText))
Dim str As String = ""
For i As Integer = 0 To j
str = [login to view URL](str, [login to view URL]("{0:x02}", bs(i)))
Next i
MyMD5CryptoServiceProvider = Nothing
Return str
End Function
End Class
' Crypt
Dim wrapper As New Simple3Des(Generatehash([login to view URL], False))
Dim EncrypedPassword As String = [login to view URL](Password)
' Decrypt
Dim wrapper As New Simple3Des(Generatehash([login to view URL], False))
Dim Password As String = [login to view URL](EncrypedPassword)
================
Hi, We have excellent eCommerce .Net,and PHP expertise.
Please have a look at private message for relevant work done.
Awaiting a positive response from your end and looking forward to work with you. Thanks