Encapsulation | encryption | decryption using System;
Using System.Text;
Using System.Globalization;
Using System.Security.Cryptography;
Using System.Windows.Forms;
Namespace Jh.encrypts
{
public class Jhencrypt
{
<summary>
Construction method
</summary>
Public Jhencrypt ()
{
}
<summary>
Encrypt with default key string
</summary>
<param name= "original" > Clear text </param>
<returns> redaction </returns>
public static string Encrypt (string original)
{
Return Encrypt (Original, "Jasonheung");
}
<summary>
Decrypting with the default key
</summary>
<param name= "original" > Redaction </param>
<returns> Clear Text </returns>
public static string Decrypt (string original)
{
Return Decrypt (Original, "Jasonheung", System.Text.Encoding.Default);
}
<summary>
Decrypts with a given key
</summary>
<param name= "original" > Redaction </param>
<param name= "key" > Key </param>
<returns> Clear Text </returns>
public static string Decrypt (string original, String key)
{
Return Decrypt (Original,key,system.text.encoding.default);
}
<summary>
Decrypts using the default key, returning the specified encoding plaintext
</summary>
<param name= "original" > Redaction </param>
<param name= "encoding" > Coding mode </param>
<returns> Clear Text </returns>
public static string Decrypt (String original,encoding Encoding)
{
Return Decrypt (Original, "Jasonheung", encoding);
}
<summary>
Encrypt with a given key
</summary>
<param name= "original" > Original text </param>
<param name= "key" > Key </param>
<param name= "Encoding" > character encoding scheme </param>
<returns> redaction </returns>
public static string Encrypt (string original, String key)
{
byte[] Buff = System.Text.Encoding.Default.GetBytes (original);
Byte[] KB = System.Text.Encoding.Default.GetBytes (key);
Return convert.tobase64string (Encrypt (BUFF,KB));
}
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.