How to encrypt files is the safest? _ Programming 10000 Q

Source: Internet
Author: User

<%@ Language = vbscript%>
<%

Response.Expires = 0


p = "ABCDEFG"
Set testpwd = New Cpassword
TESTPWD.ENPWD P
Testpwd.unpwd testpwd.showpwd (True)

K = Testpwd.showpwd (True)
L = testpwd.showpwd (False)
Set testpwd = Nothing

With Response
. Write "Original: "& P &" <br> "
. Write "After encryption: "& K &" <br> "
. Write "After decryption: "& L &" <br> "
End With


Class Cpassword
Private cenpwd,cunpwd

Private Function My_hex (My_hex_source)
My_hex = Hex (My_hex_source)
If Len (My_hex) = 1 Then
My_hex = "0" & My_hex
End If
End Function

Private Function My_unhex (My_unhex_source)
If Len (My_unhex_source) = 2 Then
Temp_value = My_hexreplace (left (my_unhex_source,1))
End If
My_unhex = Temp_value * + my_hexreplace (right (my_unhex_source,1))
End Function

Private Function my_hexreplace (My_hexreplace_source)
If ASC (my_hexreplace_source) > Then
My_hexreplace = ASC (UCase (My_hexreplace_source))-55
Else
My_hexreplace = ASC (my_hexreplace_source)-48
End If
End Function

Public Property Get Showpwd (EnP)

'Output.
If EnP Then
Showpwd = Cenpwd
Else
Showpwd = Cunpwd
End If
End Property

Sub enpwd (Enpwd_source)
If Enpwd_source = "" Then
CENPWD = 0
Exit Sub
Else
Randomize
Key = Rnd * 256
While Key = 0
Key = Rnd * 256
Wend
For I=1 to Len (Enpwd_source)
temp_string = Key Xor Asc (Mid (enpwd_source,i,1))
CRC = CRC + Temp_string
Cenpwd = cenpwd + My_hex (temp_string)
Next
Cenpwd = My_hex (Key) + strreverse (cenpwd) + my_hex (CRC Mod 256)
End If
End Sub

Sub unpwd (Unpwd_source)
If Len (Unpwd_source) < 6 Or len (unpwd_source) Mod 2 = 1 Then
CUNPWD = 0
Exit Sub
End If
Old_key = My_unhex (left (unpwd_source,2))
OLD_CRC = My_unhex (Right (unpwd_source,2))
old_string = StrReverse (Mid (Unpwd_source,3,len (Unpwd_source)-4))
For I=1 to Len (old_string)-1 Step 2
Temp_value = My_unhex (Mid (old_string,i,2))
Crc_temp = crc_temp + temp_value
temp_string = temp_string + Chr (temp_value Xor Old_key)
Next
If OLD_CRC <> (crc_temp Mod 256) Then
CUNPWD = 403
Exit Sub
End If
Cunpwd = temp_string
End Sub
End Class

%>

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.