SHA1 (and the full cryptography namespace) is missing in Visual Studio 2012

I copied this code from MSDN:

using System.Security.Cryptography; byte[] buffer = enc.GetBytes(text); SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider(); string hash = BitConverter.ToString( cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", ""); return hash; 

but VS says there is no such Cryptography namespace, so the SHA1CryptoServiceProvider class SHA1CryptoServiceProvider missing.

What am I doing wrong?

I am using Visual Studio Professional 2012 RC with a Dreamspark license in the Windows 8 Release Preview.

+7
source share
4 answers

I understand that you are trying to create a Metro app? Metro style apps do not support the System.Security.Cryptography . A complete list of supported .NET API namespaces for Metro applications can be found here .

UPDATE JUNE 29

As Guillermo noted, there is a Windows.Security.Cryptograhy.Core namespace containing a HashAlgorithmProvider , where, for example, the SHA1 algorithm can be applied.

+5
source

The answer, like Anders Gustafsson, indicated that Metro System.Security.Cryptography not supported. BUT you are using Windows.Security.Cryptography .

+5
source

Try adding System.Security to your project links.

Your error seems to be caused by a missing link.

http://msdn.microsoft.com/en-us/library/wkze6zky (v = vs .110) .aspx

+1
source
0
source

All Articles