I need to create a sha256 hash of a password entered in a TextBox
. I tried to use ComputeHash(string)
but it only works with streams.
Asked
Active
Viewed 3,546 times
0

erosfabbri
- 37
- 1
- 8
-
1This could give you the tip needed.https://stackoverflow.com/questions/1879395/how-do-i-generate-a-stream-from-a-string – Steve Feb 20 '20 at 19:06
-
@Steve link is good for starters, but if looking at the accepted answer there, remember the encoding isn't in place and which may be of importance. – Trevor Feb 20 '20 at 20:38
-
1@Çöđěxěŕ yes, there is a very important comment under the accepted answer and the second upvoted answer addresses it even better. – Steve Feb 20 '20 at 20:46
-
1Maybe: `Dim hash = New System.Security.Cryptography.SHA256Managed().ComputeHash(System.Text.Encoding.UTF8.GetBytes("The-password"))`. Also check [Rfc2898DeriveBytes](https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.rfc2898derivebytes?view=netframework-4.8) – Feb 20 '20 at 20:59
-
2Yeah, this is a method with a few overloads, so the "only works with streams" part is a bad preconception. And more importantly, the idea that you use a cryptographic hash on a password is probably another one. – Maarten Bodewes Feb 20 '20 at 22:38
1 Answers
1
Dim hash = New System.Security.Cryptography.SHA256Managed().ComputeHash(System.Text.Encoding.UTF8.GetBytes("The-password"))

erosfabbri
- 37
- 1
- 8