VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Xor Encryption/Decryption and Password Distribution Fuction

by Cyrus Lacaba (3 Submissions)
Category: OLE/COM/DCOM/Active-X
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Tue 18th July 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Xor Encryption/Decryption and Password Distribution Fuction

API Declarations


Private strEncrypted$


Rate Xor Encryption/Decryption and Password Distribution Fuction



Public Property Get Encrypted() As String
    Encrypted = strEncrypted$
End Property

Function EncDecryptData(ByVal strval$, ByVal blndec As Boolean, Optional lngEncDecVal& = 3) As String
Dim strOutput$, _
    PWDArr(), _
    inttnochar&, i&

    ReDim PWDArr(Len(strval$))
    
    If blndec = False Then
        'Encrypt
        For i& = 1 To Len(strval$)
            PWDArr(i&) = Asc(Mid(strval$, i&, 1))
            PWDArr(i&) = PWDArr(i&) Xor lngEncDecVal&
            PWDArr(i&) = Chr(PWDArr(i&) + 10)
        Next
        strOutput$ = Join(PWDArr, vbNullString)
        strEncrypted$ = strOutput$
    Else
        'Decrypt
        For i& = 1 To Len(strval$)
            PWDArr(i&) = Asc(Mid(strval$, i&, 1))
        Next
        strval$ = ""
        
        For i& = LBound(PWDArr) + 1 To UBound(PWDArr)
            PWDArr(i&) = Chr(PWDArr(i&) - 10)
            PWDArr(i&) = Asc(PWDArr(i&)) Xor lngEncDecVal&
            strval$ = strval$ + Chr(PWDArr(i&))
        Next
        strOutput$ = strval$
    End If

    EncDecryptData = strOutput$

End Function

Function Distribute(ByVal strval$, ByVal intDestribute%, ByVal strSeparator$) As String
Dim a, b, c, d, e, f, g, H, i, i2
Dim separator_arr(), strsptr$
Dim X As StdFont


    ReDim separator_arr(Len(strSeparator$))
    
    For i2 = 1 To Len(strSeparator$)
        separator_arr(i2) = Mid$(strSeparator$, 1, 1)
        strSeparator$ = Mid$(strSeparator$, 2)
    Next
    
    On Error GoTo Attached_Separator
    a = Len(Trim(strval$))
    If a = 0 Then Exit Function
    
    H = Mid(CStr(Len(strval$) / intDestribute%), 1, InStr(1, CStr(Len(strval$) / intDestribute%), ".") - 1)
    b = CLng(H)
    c = Len(strval$) Mod intDestribute%
    e = vbNullString
    f = vbNullString
    
    On Error GoTo Attached_Other
    For i = 1 To b
        d = Len(e) + 1
        e = e + Mid(strval$, d, intDestribute%)
        g = g + Mid(e, d, intDestribute%)
        f = f + Mid(e, d, intDestribute%) & separator_arr(i)
    Next
    
    f = f + Mid(strval$, (Len(g) - intDestribute%) + 1)
    Distribute = f
    Exit Function
    
Attached_Other:
    
    If Err = 9 Then
        f = f + Mid(strval$, (Len(g) - intDestribute%) + 1)
    End If
    Distribute = f
    Exit Function
    
Attached_Separator:
    Distribute = Join(separator_arr, vbNullString)
End Function



Download this snippet    Add to My Saved Code

Xor Encryption/Decryption and Password Distribution Fuction Comments

No comments have been posted about Xor Encryption/Decryption and Password Distribution Fuction. Why not be the first to post a comment about Xor Encryption/Decryption and Password Distribution Fuction.

Post your comment

Subject:
Message:
0/1000 characters