C# Quoted-Printable編碼、解碼
# using System;
# using System.Collections;
# using System.Text;
#
# /// <summary>
# /// Class for encoding and decoding a string to QuotedPrintable
# /// RFC 1521 http://www.ietf.org/rfc/rfc1521.txt
# /// RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
# /// Date: 2006-03-23
# /// Author: Kevin Spaun
# /// Company: SPAUN Informationstechnik GmbH - http://www.spaun-it.com/
# /// Feedback: kspaun@spaun-it.de
# /// License: This piece of code comes with no guaranties. You can use it for whatever you want for free.
# ///
# /// Modified by Will Huang ( http://blog.miniasp.com/post/2008/02/14/Quoted-Printable-Encoding-and-Decoding.aspx )
# /// Modified at 2008-02-13
# ///
# /// Modified by reterry (http://www.dbjr.com.cn)
# /// Modified at 2008-11-29
# /// Modified for MySelf
# ///
# /// </summary>
# public class QuotedPrintable
# {
# private const byte EQUALS = 61;
# private const byte CR = 13;
# private const byte LF = 10;
# private const byte SPACE = 32;
# private const byte TAB = 9;
#
# /// <summary>
# /// Encodes a string to QuotedPrintable
# /// </summary>
# /// <param name="_ToEncode">String to encode</param>
# /// <returns>QuotedPrintable encoded string</returns>
# public static string Encode(string _ToEncode)
# {
# StringBuilder Encoded = new StringBuilder();
# string hex = string.Empty;
# //byte[] bytes = Encoding.Default.GetBytes(_ToEncode);
# byte[] bytes = Encoding.UTF8.GetBytes(_ToEncode);
# //int count = 0;
#
# for (int i = 0; i < bytes.Length; i++)
# {
# //these characters must be encoded
# if ((bytes[i] < 33 || bytes[i] > 126 || bytes[i] == EQUALS) && bytes[i] != CR && bytes[i] != LF && bytes[i] != SPACE)
# {
# if (bytes[i].ToString("X").Length < 2)
# {
# hex = "0" + bytes[i].ToString("X");
# Encoded.Append("=" + hex);
# }
# else
# {
# hex = bytes[i].ToString("X");
# Encoded.Append("=" + hex);
# }
# }
# else
# {
# //check if index out of range
# if ((i + 1) < bytes.Length)
# {
# //if TAB is at the end of the line - encode it!
# if ((bytes[i] == TAB && bytes[i + 1] == LF) || (bytes[i] == TAB && bytes[i + 1] == CR))
# {
# Encoded.Append("=0" + bytes[i].ToString("X"));
# }
# //if SPACE is at the end of the line - encode it!
# else if ((bytes[i] == SPACE && bytes[i + 1] == LF) || (bytes[i] == SPACE && bytes[i + 1] == CR))
# {
# Encoded.Append("=" + bytes[i].ToString("X"));
# }
# else
# {
# Encoded.Append(System.Convert.ToChar(bytes[i]));
# }
# }
# else
# {
# Encoded.Append(System.Convert.ToChar(bytes[i]));
# }
# }
# //if (count == 75)
# //{
# // Encoded.Append("=\r\n"); //insert soft-linebreak
# // count = 0;
# //}
# //count++;
# }
#
# return Encoded.ToString();
# }
#
# /// <summary>
# /// Decodes a QuotedPrintable encoded string
# /// </summary>
# /// <param name="_ToDecode">The encoded string to decode</param>
# /// <returns>Decoded string</returns>
# public static string Decode(string _ToDecode)
# {
# //remove soft-linebreaks first
# //_ToDecode = _ToDecode.Replace("=\r\n", "");
#
# char[] chars = _ToDecode.ToCharArray();
#
# byte[] bytes = new byte[chars.Length];
#
# int bytesCount = 0;
#
# for (int i = 0; i < chars.Length; i++)
# {
# // if encoded character found decode it
# if (chars[i] == '=')
# {
# bytes[bytesCount++] = System.Convert.ToByte(int.Parse(chars[i + 1].ToString() + chars[i + 2].ToString(), System.Globalization.NumberStyles.HexNumber));
#
# i += 2;
# }
# else
# {
# bytes[bytesCount++] = System.Convert.ToByte(chars[i]);
# }
# }
#
# //return System.Text.Encoding.Default.GetString(bytes, 0, bytesCount);
# return System.Text.Encoding.UTF8.GetString(bytes, 0, bytesCount);
# }
# }
- C#編寫(xiě)的Base64加密和解密類(lèi)
- C#對(duì)二進(jìn)制數(shù)據(jù)進(jìn)行base64編碼的方法
- C#解碼base64編碼二進(jìn)制數(shù)據(jù)的方法
- C#實(shí)現(xiàn)基于Base64的加密解密類(lèi)實(shí)例
- Base64編碼解碼原理及C#編程實(shí)例
- c# Base64編碼和圖片的互相轉(zhuǎn)換代碼
- asp.C#實(shí)現(xiàn)圖片文件與base64string編碼解碼
- C# Base64編碼
- C# Base64編碼函數(shù)
- JS與C#編碼解碼
- C#實(shí)現(xiàn)Base64處理的加密解密,編碼解碼示例
相關(guān)文章
Asp.net內(nèi)置對(duì)象之Request對(duì)象(概述及應(yīng)用)
Request對(duì)象主要用于獲取來(lái)自客戶(hù)端的數(shù)據(jù),如用戶(hù)填入表單的數(shù)據(jù)、保存在客戶(hù)端的Cookie等,本文將圍繞Request對(duì)象,講解其的主要作用:讀取窗體變量、讀取查詢(xún)字符串變量、取得Web服務(wù)器端的系統(tǒng)信息。取得客戶(hù)端瀏覽器信息等等,感興趣的朋友可以了解下2013-02-02asp.net下出現(xiàn)其中的組件“訪(fǎng)問(wèn)被拒絕”的解決方法
asp.net下出現(xiàn)其中的組件“訪(fǎng)問(wèn)被拒絕”的解決方法...2007-04-04asp.net core mvc實(shí)現(xiàn)偽靜態(tài)功能
這篇文章主要為大家詳細(xì)介紹了asp.net core mvc實(shí)現(xiàn)偽靜態(tài)功能的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02靜態(tài)gb2312編碼在項(xiàng)目傳值出現(xiàn)中文亂碼現(xiàn)象
參考的美工靜態(tài)頁(yè)面是gb2312格式的,當(dāng)此編碼拿到項(xiàng)目中后,utf-8編碼的系統(tǒng),加載頁(yè)面時(shí),會(huì)出現(xiàn)樣式問(wèn)題,比如不能正常居中等2013-06-06asp.net 動(dòng)態(tài)生成控件并獲取其值
代碼比較簡(jiǎn)單,所以不多做解釋了:2009-02-02asp.net 身份驗(yàn)證機(jī)制實(shí)例代碼
對(duì)于ASP.NET驗(yàn)證機(jī)制在項(xiàng)目開(kāi)發(fā)中運(yùn)用,會(huì)使項(xiàng)目非常方便快捷的實(shí)現(xiàn)頁(yè)面的訪(fǎng)問(wèn)權(quán)限問(wèn)題,而且省去了一些沒(méi)必要的安全問(wèn)題2012-06-06ASP.NET Core使用EF創(chuàng)建模型(必需和可選屬性、最大長(zhǎng)度、并發(fā)標(biāo)記、陰影屬性)
這篇文章介紹了ASP.NET Core使用EF創(chuàng)建模型的的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-04-04ASP.NET Core部署前期準(zhǔn)備 使用Hyper-V安裝Ubuntu Server 16.10
這篇文章主要為大家詳細(xì)介紹了ASP.NET Core部署的前期準(zhǔn)備,使用Hyper-V安裝Ubuntu Server 16.10,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04