Arun
Arun

Reputation: 3456

Sha256 + salt algorithem in windows phone 7

I want to encrypt my userid and password using SHA256 algorithm and salt key for sending to the server through a xml. How can I achieve this ?

I did a sample code with SHA256 and pasted bleow. How I use salt key in this ?

      void myBtn_Click(object sender, RoutedEventArgs e)
      {
        var sha = new  SHA256Managed();
        var bytes = System.Text.Encoding.UTF8.GetBytes(testPass.Text);
        byte[] resultHash = sha.ComputeHash(bytes);
        string sha256 = ConvertToString(resultHash);
      }

       public static string ConvertToString(byte[] buff)
       {
         string sbinary = "";

         for (int i = 0; i < buff.Length; i++)
         {
             //hex-formatted
            sbinary += buff[i].ToString("X2");
         }
         return (sbinary);
       }

Upvotes: 0

Views: 350

Answers (1)

Jeremy Pullicino
Jeremy Pullicino

Reputation: 60

SHA is a hash algorithm and not an encryption algorithm. The password cannot be extracted from your result string. Are you sure you are taking the right approach? Would you care to explain the scenario a bit better?

Upvotes: 1

Related Questions