Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Web.UI.WebControls;
- using System.Security.Cryptography;
- using System.Text;
- namespace JSVirtualKeyboard
- {
- public partial class WebForm2 : System.Web.UI.Page
- {
- private string Encrypt(string txttoEncrypt)
- {
- string EcriptedData = string.Empty;
- byte[] txt_encode = new byte[txttoEncrypt.Length];
- txt_encode = Encoding.UTF8.GetBytes(txttoEncrypt);
- EcriptedData = Convert.ToBase64String(txt_encode);
- return EcriptedData;
- }
- private string Decrypt(string txttoDecrypt)
- {
- UTF8Encoding encode_pwd = new UTF8Encoding();
- string DecryptedData = string.Empty;
- Decoder Decode = encode_pwd.GetDecoder();
- byte[] todecodeByte = Convert.FromBase64String(txttoDecrypt);
- int charCount = Decode.GetCharCount(
- todecodeByte,
- 0,
- todecodeByte.Length
- );
- char[] decoded_char = new char[charCount];
- Decode.GetChars(todecodeByte, 0, todecodeByte.Length, decoded_char, 0);
- DecryptedData = new String(decoded_char);
- return DecryptedData;
- }
- protected void btnencrypt_Click(object sender, EventArgs e)
- {
- TextBox2.Text = Encrypt(TextBox1.Text);
- }
- protected void btndecrypt_Click(object sender, EventArgs e)
- {
- TextBox1.Text = Decrypt(TextBox2.Text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement