revolutionkpi
revolutionkpi

Reputation: 2682

SHA-1 Algorithm in Windows Phone

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";

Upvotes: 2

Views: 2093

Answers (3)

ie.
ie.

Reputation: 6101

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

Upvotes: 0

vcsjones
vcsjones

Reputation: 141678

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);

Upvotes: 5

SHA1 sha = new SHA1CryptoServiceProvider(); 
byte[] result = sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(text));

Upvotes: 0

Related Questions