Some of the previously collected data---Encrypt your data using an ASP encryption Algorithm (i)

Source: Internet
Author: User
Encryption | data | Some previous data collected by the algorithm---encrypt your data using an ASP encryption Algorithm (i)
Brief introduction
First, a brief introduction to the background of encryption. Because the United States prohibits the export of several cryptographic algorithms
Encrypted digits (such as SSL's 40-bit encryption limit), this article introduces a simple character encryption algorithm that can be used by ASP.
Instead of those restricted encryption algorithms. In fact, the encryption algorithm introduced here is sufficient for the general application
The decryption man is in trouble for a while. Its encryption base is the simplest Vernum password method, and I will in the next article
Introduce this password.
Its rationale is that there is a need to encrypt the plaintext and a randomly generated decryption key file. And then
Use these two files together to generate the ciphertext.
(plaintext) combination (key) = encrypted ciphertext
So this article is about the code that generates the key. We assume that the key we generate is a 512-bit long key,
It's enough to encrypt a text character. The code is as follows:
keygen.asp file
<%
'******************************
' Keygen.asp
'******************************
Const g_keylocation = "C:\key.txt"
Const G_keylen = 512

On Error Resume Next

Call Writekeytofile (KeyGeN (G_keylen), g_keylocation)

If ERR <> 0 Then
Response.Write "ERROR generating KEY." & "<P>"
Response.Write Err.Number & "<BR>"
Response.Write Err.Description & "<BR>"
Else
Response.Write "KEY successfully generated."
End If

Sub Writekeytofile (Mykeystring,strfilename)
Dim KeyFile, FSO
Set fso = Server.CreateObject ("Scripting.") FileSystemObject ")
Set keyfile = FSO. CreateTextFile (strFileName, True)
Keyfile.writeline (mykeystring)
Keyfile.close
End Sub

Function KeyGeN (ikeylength)
Dim K, icount, Strmykey
Lowerbound = 35
Upperbound = 96
Randomize ' Initialize random-number generator.
For i = 1 to Ikeylength
s = 255
K = Int (((upperbound-lowerbound) + 1) * Rnd + lowerbound)
Strmykey = Strmykey & Chr (k) & ""
Next
KeyGeN = Strmykey
End Function

%>
Run the above keygen.asp page under IIS. You just have to do it once, he will write the key to the file
C:\key.txt (If you like, you can also put this file in another safer place).
You can then open the Key.txt file, which will contain 512 ASCII characters between 35 and 96.
And because it is randomly generated, everyone's private key file Key.txt will be different, and the following is
One example key file:
iy/;$>=3)? ^-+7m32#q]voii. Q=OFMC ':P 7_b;<r/8u) xfhc<sr_e$. DLG ' =i+@5%*+op:f_= '; '
Nsy '-^s. ' Aa=bj3m0. WF#T5LGK (=/<:+c2k/^7ai$; PU ' Ome2+t8nd? W$c (j\,;631 ' m-ld5f%%1
tf_&k2a-d-54[2p,# ' *ju%6 ' 0rf3cmf0 (#T07U ' fz=>#,+. aw_/+ ']dib;2dtia57tt&-' O '/*f '
m>h.xh5w^0y*=71+5*^ ' ^pkj (=e/x#7a:?,s>r&t;+b#<:-*\@) x9f ' _ '%qa3z95.? _t#1,$2#fw
W5PBH^*&LT] A (s0@avd8c^q0r^t1d?) ( 1+,YE71X+.*+U$:3XO^Q]. kg&0n0]; [LJ&LT;OZ6IN?7N4&LT;GT
L? (M ' 4S8+3JMK5] Hc%^1^+k;\ $WBXPA? F&5^e\d$7%*o/u[1/?8 ( 5:1ovwv*1z-% ': K&v? X1,1ku
RD@3W0^D) <og40? (vj4ewl5a5m< $A); cq36r9i]*u#q%1<y\&sa% #1 <v
The following is a careful analysis of the above procedures, we found that the lowerbound and Upperbound values
is actually the range of ASCII characters you want to use to encrypt.
The following article describes how to use this key to encrypt and decrypt a string



Related Article

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.