A set of functions to decrypt strings

Source: Internet
Author: User
Tags exit chr decrypt
function | decryption | string <%
Function Encrypt (Thenumber)
On Error Resume Next
Dim N, Szenc, T, HiN, LoN, I
n = CDBL ((thenumber + 1570) ^ 2-7 * (Thenumber + 1570)-450)
If N < 0 Then Szenc = "R" Else szenc = "J"
n = CStr (ABS (n))
For i = 1 to Len (n) Step 2
t = Mid (n, I, 2)
If Len (t) = 1 Then
Szenc = Szenc & T
Exit for
End If
HiN = (CInt (t) and 240)/16
LoN = CInt (t) and 15
Szenc = Szenc & CHR (ASC ("M") + HiN) & CHR (ASC ("C") + LoN)
Next
Encrypt = Szenc
End Function

Function Decrypt (Thenumber)
On Error Resume Next
Dim e, N, sign, T, HiN, LoN, newn, I
E = Thenumber
If left (e, 1) = "R" Then sign =-1 Else sign = 1
E = Mid (E, 2)
newn = ""
For i = 1 to Len (e) Step 2
t = Mid (E, I, 2)
If ASC (T) >= ASC ("0") and ASC (T) <= ASC ("9") Then
newn = newn & T
Exit for
End If
HiN = Mid (t, 1, 1)
LoN = Mid (T, 2, 1)
HiN = (ASC (HiN)-ASC ("M")) * 16
LoN = ASC (LoN)-ASC ("C")
t = CStr (HiN Or LoN)
If Len (t) = 1 Then t = "0" & T
newn = newn & T
Next
E = CDBL (newn) * Sign
Decrypt = CLng ((7 + SQR (49-4 * ( -450-E)))/2-1570)
End Function
%>
Original number:69 <br>
Encrypt (RETURNS:JNMQMOJ8) <br>
Decrypt ("JNMQMOJ8") returns:69
<p>
Another example using variables instead: <br>
Encrypt (Request.Form ("ID")) <br>
Encrypt (MyVar) <br>
Decrypt (Request.QueryString ("id")) <br>
Decrypt ("JNMQMOJ8") <br>
Decrypt (MyVar)

</body>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.