資源簡介
/// <summary>
/// Base64解密
/// </summary>
/// <param name="Message">需要解密的加密字符串</param>
/// <returns>解密后的字符串</returns>
static public string Base64Decode(string Message)
{
if ((Message.Length % 4) != 0)
{
throw new ArgumentException("不是正確的BASE64編碼,請檢查。", "Message");
}
if (!System.Text.RegularExpressions.Regex.IsMatch(Message, "^[A-Z0-9/ =]*$", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
throw new ArgumentException("包含不正確的BASE64編碼,請檢查。", "Message");
}
string Base64Code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 /=";
int page = Message.Length / 4;
System.Collections.ArrayList outMessage = new System.Collections.ArrayList(page * 3);
char[] message = Message.ToCharArray();
for (int i = 0; i < page; i )
{
byte[] instr = new byte[4];
instr[0] = (byte)Base64Code.IndexOf(message[i * 4]);
instr[1] = (byte)Base64Code.IndexOf(message[i * 4 1]);
instr[2] = (byte)Base64Code.IndexOf(message[i * 4 2]);
instr[3] = (byte)Base64Code.IndexOf(message[i * 4 3]);
byte[] outstr = new byte[3];
outstr[0] = (byte)((instr[0] << 2) ^ ((instr[1] & 0x30) >> 4));
if (instr[2] != 64)
{
outstr[1] = (byte)((instr[1] << 4) ^ ((instr[2] & 0x3c) >> 2));
}
else
{
outstr[1] = 0;//outstr[2] = 0;??
}
if (instr[3] != 64)
{
outstr[2] = (byte)((instr[2] << 6) ^ instr[3]);
}
else
{
outstr[2] = 0;
}
outMessage.Add(outstr[0]);
if (outstr[1] != 0)
outMessage.Add(outstr[1]);
if (outstr[2] != 0)
outMessage.Add(outstr[2]);
}
byte[] outbyte = (byte[])outMessage.ToArray(Type.GetType("System.Byte"));
return System.Text.Encoding.Default.GetString(outbyte);
//return System.Text.Encoding.ASCII.GetString(outbyte);
}
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Net;
using?System.Text;
namespace?base64WindowsApplication17
{
????class?Class1
????//?public?class?base64Protector
????{
????????///?
????????///?base64加密
????????///?
????????///?需要加密的字符串
????????///?加密后的字符串
????????static?public?string?base64Code(string?Message)
????????{
????????????char[]?base64Code?=?new?char[]{‘A‘‘B‘‘C‘‘D‘‘E‘‘F‘‘G‘‘H‘‘I‘‘J‘‘K‘‘L‘‘M‘‘N‘‘O‘‘P‘‘Q‘‘R‘‘S‘‘T‘
????????????????????‘U‘‘V‘‘W‘‘X‘‘Y‘‘Z‘‘a‘‘b‘‘c‘‘d‘‘e‘‘f‘‘g‘‘h‘‘i‘‘j‘‘k‘‘l‘‘m‘‘n‘
????????????????????‘o‘‘p‘‘q‘‘r‘‘s‘‘t‘‘u‘‘v‘‘w‘‘x‘‘y‘‘z‘‘0‘‘1‘‘2‘‘3‘‘4‘‘5‘‘6‘‘7‘
?????????????????????‘8‘‘9‘‘+‘‘/‘‘=‘};
??????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-09-19?16:22??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????文件???????55808??2017-09-19?16:28??ba
?????目錄???????????0??2017-09-19?16:28??ba
?????文件?????????187??2017-02-28?22:37??ba
?????文件????????5784??2017-03-07?14:40??ba
?????文件????????5360??2017-06-30?22:17??ba
?????文件????????1205??2017-09-19?16:28??ba
?????文件????????5817??2017-06-30?22:17??ba
?????文件?????????536??2017-02-28?22:37??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????文件????????1386??2017-02-28?22:37??ba
?????文件????????2900??2017-02-28?22:37??ba
?????文件????????5612??2017-02-28?22:37??ba
?????文件????????1111??2017-02-28?22:37??ba
?????文件?????????249??2017-02-28?22:37??ba
?????文件????????5446??2017-02-28?22:54??ba
?????文件?????????477??2017-02-28?22:54??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????文件??????150016??2017-06-30?22:29??ba
?????文件?????????187??2017-02-28?22:37??ba
?????文件???????26112??2017-06-30?22:29??ba
?????文件???????22984??2017-04-13?11:38??ba
?????文件?????????187??2017-02-28?22:37??ba
?????文件?????????490??2014-01-13?21:31??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????目錄???????????0??2017-09-19?16:22??ba
?????文件??????????42??2017-09-19?16:24??ba
............此處省略16個文件信息
- 上一篇:國稅總局開放發票導入xm
l生成算法DEMO - 下一篇:C# 調用阿里短信接口發短信
評論
共有 條評論
相關資源
- adsl 自動撥號類 源碼
- C# 讀取并編輯window系統的右鍵菜單
- 通過C#自帶的頭文件(類)獲取Windo
- C#獲取電腦CPU以及內存使用率
- Syndication實現讀取、創建、訂閱、更新
- jQuery lazyload-預加載 功能,已經通過運
- tf-idf一種計算方法
- httpclient source code by csharp
- NServiceKit.Redis 基礎操作
- XXTEA算法的C#實現和JS實現,可以互相
- Prodave6聯接程序源碼
- UDP Messenger 1.0.unitypackage
-
C# 播放鈴聲(AxWindowsMediaPla
yer)最新 - wpf實現展開收縮效果(ShrinkSpread)
- C# FileStream寫入檔案、StreamReader讀取、
- C# 透過 Google map Geocoder API 以經緯度
- DevExpress_14.1.4破解補丁
- Heizungsregler(Ein digitaler Heizungsregler)
- C#實現 用口令加密Bat文件
- C# 偽隨機數加密
- C# 異或加密數字
- 二維表
- C# 常用加密解密
- AD 操作 Helper類代碼
- NAudio實現mp3轉換成wav
- A 2D/3D force directed graph algorithm in C#
- halcon標定(基于HalconDotNet)
- Dotween.unitypackage
- C# 創建PDF文檔
- DotNetZip 解壓縮 以及分卷壓縮類