Simple local padding encryption and decryption on Windows Phone Client

Source: Internet
Author: User
Using system; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. ink; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Microsoft. phone. controls; using system. security. cryptography; // created by: vakin time: 2011-12-15namespace microblogforwp7.classes. util {// convert the input string to byte Array // then use protecteddata and pre-defined byte array for encryption // the encrypted data is also a byte data // finally use convert. tobase64string get its corresponding string public class encrypt {// pre-defined byte array: byte [] Opt = new byte [] {1, 2, 4, 8, 16 }; /// <summary> /// encryption of the password /// </Summary> /// <Param name = "userpassword"> unencrypted password content </param> /// <returns> </returns> private string encryptpwd (string userpassword) {byte [] input = system. text. encoding. utf8.getbytes (userpassword); String result = convert. tobase64string (protecteddata. Protect (input, OPT); return result ;}/// <summary >/// decrypt and decode. Null // </Summary> /// <Param name = "userpassword"> encrypted password content </param> /// <returns> </returns> private string decryptpwd (string userpassword) {If (string. isnullorempty (userpassword) {// return NULL without an encrypted password;} byte [] Output = convert. frombase64string (userpassword); byte [] en = protecteddata. unprotect (output, OPT); string result = system. text. encoding. utf8.getstring (EN, 0, en. length); return result ;}}}

Related Article

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.