I have a WCF Service and I want to pass a SHA1 hashed string as a result.
On the client side, I have a simple html page with javascript.
I have the code to make the SHA1 string in javascript and I want to use it for both client (dehash the message) and server (hash the message).
The server is in C#.
So, is it possible to call the SHA1 javascript function from C#?
This doesn’t make sense for two reasons:
1) You can’t really share code between C# and JS, these languages are created for completely different purposes and are not interoperable, unless you are willing to allow code generation mess (like in ASP .NET Web Forms). Still, this looks like abuse of DRY that hurts in the long run.
2) SHA1 is one-way algorithm, there is no way to de-hash an encoded string (not talking rainbow tables here). You’re using a wrong tool for the job.