NetSkycn.Security/DESProvider.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace NetSkycn.Security
{
/// <summary>
/// DESEncrypt加密解密算法。
/// </summary>
public sealed class DESProvider
{
private DESProvider()
{
}
private static string key = "netskycn";
/// <summary>
/// 对称加密解密的密钥
/// </summary>
public static string Key
{
get
{
return key;
}
set
{
key = value;
}
}
/// <summary>
/// DES加密
/// </summary>
/// <param name="encryptString">要加密的字符串</param>
/// <returns></returns>
public static string Encrypt(string encryptString)
{
if (string.IsNullOrEmpty(encryptString))
{
throw new ArgumentNullException("encryptString", "不能为空");
}
byte[] keyBytes = Encoding.UTF8.GetBytes(key.Substring(0, 8));
byte[] keyIV = keyBytes;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, provider.CreateEncryptor(keyBytes, keyIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
return Convert.ToBase64String(mStream.ToArray());
}
/// <summary>
/// DES解密
/// </summary>
后面还有 20 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。