2015-10-20 14 views
15

Bu class benim coreclr projemde kullanıyorum ama SHA256Managed için doğru paketi bulamıyorum. System.Security.Cryptography.Algorithms ":" 4.0.0-beta-23409 "kullanmayı denedim ancak SHA2565Managed uygulamasının uygulanmasını içermiyor.Kişik değerlerin hesaplanması için başka herhangi bir alternatif var mı?CoreCLR HashAlgorithms

cevap

28

(System.Security.Cryptography.Algorithms itibaren) SHA256.Create() kullanabilirsiniz:.

using (var algorithm = SHA256.Create()) 
{ 
    // Create the at_hash using the access token returned by CreateAccessTokenAsync. 
    var hash = algorithm.ComputeHash(Encoding.ASCII.GetBytes(response.AccessToken)); 

    // Note: only the left-most half of the hash of the octets is used. 
    // See http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken 
    identity.AddClaim(JwtRegisteredClaimNames.AtHash, Base64UrlEncoder.Encode(hash, 0, hash.Length/2)); 
} 
+0

O System.Security.Cryptography' 'aslında, değil' System.Security.Cryptography.Algorithms' – Pavel

+0

@Pavel paket adı [ 'System.Security.Cryptography olduğunu .Algorithms' (https://www.nuget.org/packages/System.Security.Cryptography.Algorithms/) ve 'System.Security.Cryptography' ad alanı. – Pinpoint

+0

Oh, anladım. bir NuGet paketi. – Pavel

İlgili konular