openldap SHA

2022-06-09  本文已影响0人  价值投机168

加密:

public string StrEncrypt(string pwd)
    {
        var sha1 = new SHA1Managed();
        byte[] sha1Res = sha1.ComputeHash(Encoding.ASCII.GetBytes(pwd));
        
        byte[] joinByte = new byte[sha1Res.Length];
        sha1Res.CopyTo(joinByte, 0);
        
        string base64Str = Convert.ToBase64String(joinByte);


        byte[] aa = sha1.ComputeHash(Encoding.ASCII.GetBytes(pwd));
        string old = "";
        foreach (var item in aa)
        {

            old += item.ToString("X2");
        }

        Console.WriteLine(old);

        return "{SHA}" + base64Str;
    }

使用:

string t1 = StrEncrypt("secret");
        Console.WriteLine(t1);
上一篇 下一篇

猜你喜欢

热点阅读