Generating an MD5 Hash from a String Using LINQ
|
|
 |

|
cannot convert from 'System.Collections.Generic.IEnumerable' to 'string[]'
|
|
|
|

|
Could you post how you are using this or encountering this error? The code itself is fairly straight-forward and I would hate to have it down-voted all because of what could be a possible syntax error.
What version of .NET are you using? Did you include the appropriate references that this requires :
using System.Text;
using System.Security.Cryptography;
I would be glad to help you with any issues that you are having with it if I can.
|
|
|
|

|
Hi Rion
I'm sorry but you don't notice to .NET version.
I tried with .NET 3.5 and found this error, but it work with .NET 4.
Please specify .NET version for this article.
I will correct my vote.
Regards!
Mahdi 82161021
|
|
|
|

|
Hi Mahdi,
Firstly, thank you for your response. I have made some corrections to the article to detail handling this sample function for versions of .NET 3.5 and below. You simply need to add the .ToArray() method following the Select statement as seen below :
//For .NET 3.5 and below, you will need to use the .ToArray() following the Select method:
var hashValue = string.Join("", MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(yourStringValue)).Select(s => s.ToString("x2")).ToArray());
Hopefully that helps you out a bit.
|
|
|
|

|
That's a neat bit of coding Rion. Here is my effort. var hashValue = BitConverter.ToString(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(yourStringValue))); Best wishes.
|
|
|
|
 |
|
|
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Last Updated 7 May 2013 |
Advertise |
Privacy |
Terms of Use |
Copyright ©
CodeProject, 1999-2013