Could someone please provide guidance on how to accomplish this task?
I have successfully implemented hashing using sha1 in c#, but I am uncertain of how to achieve the same functionality using javascript.
I am eager to learn different techniques for accomplishing this. Thank you!
Edit: I have attempted to use the following link:
I am confused as to why the results from SHA1CryptoServiceProvider in c# differ from the example provided in the link above.
Here is the code that I have tried : 1. Example mentioned in the above link (javascript) 2.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button_ServerSide" onclick="Button1_Click" />
Code Behind:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Security.Cryptography;
using System.Text;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string strText = String.Empty;
strText = TextBox1.Text;
//SHA512CryptoServiceProvider encrypt = new SHA512CryptoServiceProvider();
SHA1CryptoServiceProvider encrypt = new SHA1CryptoServiceProvider();
byte[] encryptText = encrypt.ComputeHash(Encoding.Default.GetBytes(strText));
TextBox1.Text = "";
foreach (byte tempData in strText)
{
TextBox1.Text = TextBox1.Text + "x";
}
string str = System.Text.Encoding.Default.GetString(encryptText);
Response.Write("Entered Text: " + strText + " Encrypted Text Length: " + encryptText.Length + " enpwd: " + strText);
Response.Write(" encryptText: " + encryptText.Equals(strcrypt.Value));
Response.Write(" encryptText STR: " + str);
//ProtectedData.Protect();
}
}