Clothes.Comment/Encryption.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Clothes.Comment
{
    public class Encryption
    {
        public string SHA1Encryp(string Password)
        {

            // 字符串为空
            if (string.IsNullOrWhiteSpace(Password))
                return string.Empty;
            // 尝试加密
            //转换为UTF8编码的字节数组
            byte[] byteArray = Encoding.UTF8.GetBytes(Password);
            string ciphertext;
            try
            {
                byte[] cipherByte;
                using (SHA1Managed sha1 = new SHA1Managed())
                {
                    //使用SHA1加密
                    cipherByte = sha1.ComputeHash(byteArray);
                }
                //将加密的数组转换成base64
                ciphertext = Convert.ToBase64String(cipherByte);
            }
            catch (Exception ex)
            {
                // LogHelper.Error("数据加密失败", ex);
                return Password;
            }
            // 返回
            return ciphertext;
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。