1. Create a class library under. NET and add another class file
2. Define an interface and add a guid to the interface
[GUID ("47e62378-b300-43f6-bdb4-0deac60f8eb6")]
Public interface iencrypt
{
String myencoding (string SS );
String mydecoding (string SS );
}
3. Implementation Interface
[GUID ("532ff790-079a-4e2b-ab1e-6dfc7e1dfd21")]
Public class myencrypt: iencrypt
{
Public myencrypt ()
{}
// Encryption Method
Public String myencoding (string SS)
{
Repeated ricalgorithm symm = new rijndaelmanaged ();
Symm. generatekey ();
Symm. generateiv ();
Byte [] Key = symm. Key;
Byte [] IV = symm. IV;
Byte [] BS = _ getbytesfromunicode (SS );
Byte [] Be = _ dodesencoding (Key, IV, BS );
Byte [] bmd5 = (New md5cryptoserviceprovider (). computehash (BS );
Byte [] Be2 = _ combinatebytes (bmd5, key, IV, be );
Return System. Convert. tobase64string (Be2 );
}
// Decryption Method
Public String mydecoding (string SS)
{
Byte [] BS = system. Convert. frombase64string (SS );
Byte [] bs2 = _ dodesdecoding (BS );
If (bs2 = NULL)
Return NULL;
Else
Return _ getunicodefrombytes (bs2 );
}
}
4. compile and generate the dynamic link library sxcryptpwd. dll, and register the dynamic link library regasm/TLB sxcryptpwd. TLB sxcryptpwd. dll at the. NET command prompt.
In this way, the COM component is registered.
5. Application under ASP
<%
Set OBJ = server. Createobject ("myencrypt ")
Dim str1
Str1 = obj. myencoding ("test. net component") // Encrypt
Response. Write ("strencript =" & str1 & "<br> ")
Dim str2
Str2 = obj. mydecoding (str1) // decrypt
Response. Write ("strdecrypt =" & str2 & "<br> ")
%>