.NET encryption decryption method

xiaoxiao2021-03-06  64

Encoding public string EncodeBase64 (string code_type, string code) {string encode = ""; byte [] bytes = Encoding.GetEncoding (code_type) .GetBytes (code); try {encode = Convert.ToBase64String (bytes);} catch {encode = code;} return encode;} decoding public string DecodeBase64 (string code_type, string code) {string decode = ""; byte [] bytes = Convert.FromBase64String (code); try {decode = Encoding.GetEncoding (code_type) .GetString (bytes);} catch {decode = code;} return decode;} and then attach the MD5 encryption method System.Web.Security; FormsAuthentication.HashPasswordForStoringInConfigFile (toCryString, "MD5") code_typer GetEncoding selection method relies on the underlying platform supports large Partial code page. However, the system support is provided for the following case: the default code, that is, the encoding specified in the area setting of the computer that performs this method; Little-Endian Unicode (UTF-16LE); BIG-Endian Unicode (UTF-16BE); Windows operating system (Windows-1252); UTF-7; UTF-8; ASCII and GB18030 (Simplified Chinese).

Specifies one of the names listed in the table below to obtain encoding supported by the system with the corresponding code page.

Code page name "UTF-16LE", "UTF-16", "UCS-2", "Unicode" or "ISO-10646-UCS-2" UTF-16BE "or" Unicodeffe "UTF -7 "," csunicode11UTF7 "," Unicode-1-1-UTF-7 "," Unicode-2-0-UTF-7 "," X-Unicode-1-1-UTF-7 "or" X-Unicode -2-0-UTF-7 "UTF-8", "Unicode-1-1-UTF-8", "Unicode-2-0-UTF-8", "X-Unicode-1-1-UTF- 8 "or" X-Unicode-2-0-UTF-8 "" US-ASCII "," US "," ASCII "," ANSI_X3.4-1968 "," ANSI_X3.4-1986 "," CP367 ", "CSASCII", "IBM367", "ISO-IR-6", "ISO646-US" or "ISO_646.IRV: 1991" "GB18030"

Some platforms may not support specific code pages. For example, the US version of Windows 98 may not support Japanese Shift-JIS code page (code page 932). In this case, the GetEncoding method will trigger NotSupportedException when executing the following C # code:

转载请注明原文地址:https://www.9cbs.com/read-86537.html

New Post(0)