2

In my Windows Phone application I need to get hash using SHA-1 Algorithm. How can I do this? For example I have string text="1234";

revolutionkpi
  • 2,632
  • 10
  • 45
  • 84

3 Answers3

5

You would use the SHA1Managed class to compute the hash of a byte array. Probably do something like this:

var sha = new SHA1Managed(); 
var bytes = System.Text.Encoding.UTF8.GetBytes(text);
byte[] resultHash = sha.ComputeHash(bytes);
vcsjones
  • 138,677
  • 31
  • 291
  • 286
0
SHA1 sha = new SHA1CryptoServiceProvider(); 
byte[] result = sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(text));
vcsjones
  • 138,677
  • 31
  • 291
  • 286
0

You should use System.Security.Cryptography.SHA1Managed class.

ie.
  • 5,982
  • 1
  • 29
  • 44