2015-10-20 7 views
15

私はcoreclrプロジェクトにclassを使用しようとしていますが、SHA256Managedの正しいパッケージが見つからないようです。私はSystem.Security.Cryptography.Algorithms "を使用しようとしました:" 4.0.0-beta-23409 "しかし、SHA2565Managedの実装は含まれていません.CoreCLRのHashAlgorithms

答えて

28

You (System.Security.Cryptography.Algorithmsから)SHA256.Create()を使用することができます。

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

それはSystem.Security.Cryptography' 'で実際にだ、ではない' System.Security.Cryptography.Algorithms' – Pavel

+0

@Pavelパッケージ名は[ 'System.Security.Cryptographyです.Algorithms'](https://www.nuget.org/packages/System.Security.Cryptography.Algorithms/)と 'System.Security.Cryptography'という名前空間。 – Pinpoint

+0

ああ、私はそれがわかっていなかったNuGetパッケージ。 – Pavel

関連する問題