美文网首页
openldap SHA

openldap SHA

作者: 价值投机168 | 来源:发表于2022-06-09 11:38 被阅读0次

加密:

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);

相关文章

网友评论

      本文标题:openldap SHA

      本文链接:https://www.haomeiwen.com/subject/shhmmrtx.html