资源简介
C#使用 谷歌身份认证器,动态口令,GoogleAuthenticator 基于时间的一次性密码
代码片段和文件信息
using System;
namespace GoogleAuthorization
{
public static class base32
{
public static byte[] ToBytes(string input)
{
if (string.IsNullOrEmpty(input))
{
throw new ArgumentNullException(“input“);
}
input = input.TrimEnd(‘=‘);
int byteCount = input.Length * 5 / 8;
byte[] returnArray = new byte[byteCount];
byte curByte = 0 bitsRemaining = 8;
int mask = 0 arrayIndex = 0;
foreach (char c in input)
{
int cValue = CharToValue(c);
if (bitsRemaining > 5)
{
mask = cValue << (bitsRemaining - 5);
curByte = (byte)(curByte | mask);
bitsRemaining -= 5;
}
else
{
mask = cValue >> (5 - bitsRemaining);
curByte = (byte)(curByte | mask);
returnArray[arrayIndex++] = curByte;
curByte = (byte)(cValue << (3 + bitsRemaining));
bitsRemaining += 3;
}
}
if (arrayIndex != byteCount)
{
returnArray[arrayIndex] = curByte;
}
return returnArray;
}
public static string ToString(byte[] input)
{
if (input == null || input.Length == 0)
{
throw new ArgumentNullException(“input“);
}
int charCount = (int)Math.Ceiling(input.Length / 5d) * 8;
char[] returnArray = new char[charCount];
byte nextChar = 0 bitsRemaining = 5;
int arrayIndex = 0;
foreach (byte b in input)
{
nextChar = (byte)(nextChar | (b >> (8 - bitsRemaining)));
returnArray[arrayIndex++] = ValueToChar(nextChar);
if (bitsRemaining < 4)
{
nextChar = (byte)((b >> (3 - bitsRemaining)) & 31);
returnArray[arrayIndex++] = ValueToChar(nextChar);
bitsRemaining += 5;
}
bitsRemaining -= 3;
nextChar = (byte)((b << bitsRemaining) & 31);
}
if (arrayIndex != charCount)
{
returnArray[arrayIndex++] = ValueToChar(nextChar);
while (arrayIndex != charCount) returnArray[arrayIndex++] = ‘=‘;
}
return new string(returnArray);
}
private static int CharToValue(char c)
{
var value = (int)c;
if (value < 91 && value > 64)
{
return value - 65;
}
if (value < 56 && value > 49)
{
return value - 24;
}
if (value < 123 && value > 96)
{
return value - 97;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-11-13 01:22 GoogleAuthenticator-master\
文件 5850 2019-11-13 01:22 GoogleAuthenticator-master\.gitignore
文件 1004 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthenticator.sln
目录 0 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthorization\
文件 3453 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthorization\ba
文件 3420 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthorization\GoogleAuthenticator.cs
文件 2545 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthorization\GoogleAuthenticator.csproj
文件 873 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthorization\Program.cs
目录 0 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthorization\Properties\
文件 1326 2019-11-13 01:22 GoogleAuthenticator-master\GoogleAuthorization\Properties\AssemblyInfo.cs
文件 1028 2019-11-13 01:22 GoogleAuthenticator-master\README.md
- 上一篇:调取本机摄像头拍照
- 下一篇:ASP.Net文件上传管理源码
相关资源
- Protogen编译protobuf demotools.rar
- 基于GMap.ne控件的C/S模式地图开发程序
- C#调用Godex(科诚)打印机打印1,2维
- c# GPS坐标与火星坐标互转
- C# 调用GoogleEarth
- Google Authenticator in ASP.NET (C#)
- 科诚(GoDex)打印机二次开发Demo
- CefSharp 49.0.0.1 C#中的Google浏览器控件
- c#操作mongodb含完整源码
- C#实现磁盘调度的四种算法,图形化界
- C# Winform 嵌入Google浏览器 Chrome 与JS交
- C#中winform开发的地图定位-Google地图定
- fandango_score_comparison.csv
- .net平台C#MongoDB最新版操作类
- AlgorithmMan by IoriBinary Tree Sort
- WPF下基于geplugin的对google earth的开发
- GolfAir
- migomiddle-xms-master
- C#调用高德、百度及google地图api解析经
- mongodb gridfs .NET(C#) 文件存储
- C# 透過 Google map Geocoder API 以經緯度
- c# 实现 google 汉译英接口
- A 2D/3D force directed graph algorithm in C#
- MongoDB
-
ExtJS 2.x 与Google Maps ja
vasc ript API - C# 读取 apk文件信息(AndroidManifest.xm
- GoogleBookDownloader WebClient 读取网页源码
- mapx_csharp_map 采用C#+Mapx开发的地图系统
- GoogleMap_vs2008_KAIFA 常见的地图GIS二次开
- GoogleCellLoc 利用Google Map API
评论
共有 条评论