C # calls Des64.dll for encryption and decryption

Source: Internet
Author: User
Tags tostring trim
Encryption | decryption

[DllImport ("Des64.dll")]
private static extern void B64_des (StringBuilder in_str, StringBuilder out_str, string key, int lenth, uint option);
The first parameter is the string you want to decrypt, the second argument is the string to output, the third is the specified argument, the fourth is the string length, and the last is the encryption and decryption parameter. 0 Encryption 1 decryption.
[DllImport ("Des64.dll")]
private static extern int b64_size (int lenth, uint option);

<summary>
<param name= "M_str" ></param>
<param name= "M_key" ></param>
<param name= "Flag" ></param>
<returns></returns>
</summary>
public static string Keyornokey (String m_str,string m_key,uint flag)
{
int outlen = b64_size (m_str.length, flag);
StringBuilder result = new StringBuilder (0xff);
result.capacity = Outlen;
Result.length = Outlen;
StringBuilder Source = new StringBuilder (M_STR);
B64_des (Source, Result,m_key, m_str.length, flag);
string s = result.tostring (). Trim ();
Return result.tostring (). Trim ();
}

Here's a place to pay attention to. That's why we use StringBuilder. Because that parameter is variable.







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.