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";
Asked
Active
Viewed 2,086 times
2

revolutionkpi
- 2,632
- 10
- 45
- 84
-
1Duplicate of http://stackoverflow.com/questions/6485758/sha1-with-salt-on-windows-phone-7 – Ani Jun 11 '12 at 13:16
-
1@revolutionkpi That doesn't mean that the answer isn't helpful / right. – vcsjones Jun 11 '12 at 13:19
-
SHA1 is SHA1 if you need to write your own method. – Security Hound Jun 11 '12 at 13:19
-
in my case, as I wrote in my question I want to find out how to implement this in Windows Phone) – revolutionkpi Jun 11 '12 at 13:20
3 Answers
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

Karthik Kumar Viswanathan
- 1,786
- 11
- 13
-
-
@KarthikKumarViswanathan, No it isn't there on Windows Phone. The only SHA implementation available on Windows Phone 7 is `SHA1Managed`. – vcsjones Jun 11 '12 at 13:24