Easy Code to Encrypt and Decrypt
Easy Code to Encrypt and Decrypt
Rate Easy Code to Encrypt and Decrypt
(1(1 Vote))
'If same string pass this function return different
'Encryption code if decrept it returns same string
'This Function will get the string and encrypt
Public Function fcnEncrypt(valToEncrpt As String) As String
Dim strOriVal As String
Dim intEnCry As String
Dim intInc As Integer
Dim rndVal1 As Integer
Dim rndVal2 As Integer
strOriVal = valToEncrpt
rndVal1 = Round(Rnd(9) * 10)
rndVal2 = Round(Rnd(9) * 5)
If rndVal1 = 0 Then
rndVal1 = 4
End If
For intInc = 1 To Len(strOriVal)
intEnCry = Chr(Asc(Mid(strOriVal, intInc, 1)) + rndVal1 - rndVal2) & intEnCry
Next
fcnEncrypt = Chr(rndVal1) & intEnCry & Chr(rndVal2)
End Function
'Please pass the Encrypted string which is going to decrept
'This Function will get the string and decrept
'To decrept the required String
Public Function fcnDecrpt(valToDecrpt As String) As String
Dim strOriVal As String
Dim strDeCry As String
Dim intInc As Integer
Dim rndVal1 As Integer
Dim rndVal2 As Integer
strOriVal = valToDecrpt
rndVal1 = Asc(Left(strOriVal, 1))
rndVal2 = Asc(Right(strOriVal, 1))
strOriVal = Mid(strOriVal, 2, Len(strOriVal) - 2)
For intInc = 1 To Len(strOriVal)
strDeCry = Chr(Asc(Mid(strOriVal, intInc, 1)) - rndVal1 + rndVal2) & strDeCry
Next
fcnDecrpt = strDeCry
End Function
Easy Code to Encrypt and Decrypt Comments
No comments yet — be the first to post one!
Post a Comment