Dynamic libraries written by ASP calling. net

Source: Internet
Author: User

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> ")
%>

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.