sample code by the ref: http://www.htmlforums.com/asp-and-aspnet/t-sha256-encryption-in-aspnet-20-83659.html
Public Function EncryptSHA256Managed(ByVal ClearString As String) As String Dim uEncode As New UnicodeEncoding() Dim bytClearString() As Byte = uEncode.GetBytes(ClearString) Dim sha As New _ System.Security.Cryptography.SHA256Managed() Dim hash() As Byte = sha.ComputeHash(bytClearString) Return Convert.ToBase64String(hash) End Function
and why cryString[i].Tostring("X")? what does the X mean?
Hi
X mean format string, output to Hexadecimal
Best Regards
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
jcjcjc
Member
64 Points
639 Posts
How do I use Sha256 to Encrypt a String?
Jan 28, 2008 05:35 AM|LINK
I need to Encrypt a string, can you please direct me a reference information how to do?
thank you very much
vivek_iit
All-Star
17778 Points
3189 Posts
MVP
Re: How do I use Sha256 to Encrypt a String?
Jan 28, 2008 06:00 AM|LINK
Hi,
There are many online samples which you can refer to, like:
http://www.obviex.com/samples/hash.aspx
http://cs.thycotic.net/blogs/shiva_adhikari/archive/2006/09/09/SHA1_2C00_-MD5_2C00_-SHA256-and-some-C_2300_-code-snippet.aspx
Hope this helps,
Vivek
Communifire: Social Networking and Business Collaboration Platform
realfantasy
Contributor
2103 Points
309 Posts
Re: How do I use Sha256 to Encrypt a String?
Jan 28, 2008 06:03 AM|LINK
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22134135.html
sample code by the ref: http://www.htmlforums.com/asp-and-aspnet/t-sha256-encryption-in-aspnet-20-83659.html
jcjcjc
Member
64 Points
639 Posts
Re: How do I use Sha256 to Encrypt a String?
Jan 28, 2008 06:27 AM|LINK
thank you , I am studying http://www.obviex.com/samples/hash.aspx
do you mind offer me a code of C# type ?
again really thanks for your help
jcjcjc
Member
64 Points
639 Posts
Re: How do I use Sha256 to Encrypt a String?
Jan 28, 2008 06:30 AM|LINK
sorry for asking again
about this article
http://www.obviex.com/samples/hash.aspx which said Hash Data with Salt..
what is salt? do I create it by myself? thank you
vivek_iit
All-Star
17778 Points
3189 Posts
MVP
Re: How do I use Sha256 to Encrypt a String?
Jan 28, 2008 06:43 AM|LINK
http://en.wikipedia.org/wiki/Salt_(cryptography)
Communifire: Social Networking and Business Collaboration Platform
jcjcjc
Member
64 Points
639 Posts
Re: How do I use Sha256 to Encrypt a String?
Jan 28, 2008 07:46 AM|LINK
I just found out this simple example and it works for me
can you please teach me from this code? because I can't really understand Sha256 by this code
why this code create 2 Byte (sha256Bytes and cryString) array? what is the difference between each other and what use for?
and why cryString[i].Tostring("X")? what does the X mean?
System.Security.Cryptography.SHA256 sha256 = new System.Security.Cryptography.SHA256Managed();
byte[] sha256Bytes = System.Text.Encoding.Default.GetBytes(rawString);
byte[] cryString = sha256.ComputeHash(sha256Bytes);
string sha256Str = string.Empty;
for (int i=0;i<cryString.Length;i++)
{
sha256Str += cryString[i].ToString("X");
}
return sha256Str;
another question ... what the difference if we have salt or not?
thank you very much
XiaoYong Dai...
All-Star
38310 Points
4229 Posts
Re: How do I use Sha256 to Encrypt a String?
Jan 30, 2008 07:14 AM|LINK
Hi
X mean format string, output to Hexadecimal
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
ashish-1983
Contributor
4879 Points
1257 Posts
Re: How do I use Sha256 to Encrypt a String?
Oct 23, 2009 05:22 PM|LINK
dude you are my Hero...
thnx
Gridview
Jquery
Asp.net
Fun !
ashish-1983
Contributor
4879 Points
1257 Posts
Re: How do I use Sha256 to Encrypt a String?
Oct 24, 2009 09:37 AM|LINK
can u tell me which is the best algorithm
MD5, SHA1, SHA256, SHA384, SHA 512..
i want to implement this for password security..
Gridview
Jquery
Asp.net
Fun !