What is the equivalent C# code for below Java code?
java.security.MessageDigest d = null;
d = java.security.MessageDigest.getInstance("SHA-1");
user_password = new String(d.digest());
FYI... this code returns something likd ~£ž¹_WÁÞQAÐùß9Ã0Ï which I have never done in C#.
Thanks in advance !!!
- Edited by rmaharjan Friday, April 21, 2017 2:58 PM
You could look into below thread answer
[If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]
I found the solution after spending more than 2 hours.
Below is the equivalent code that gives the same result as above Java code.
byte hashBytes = Encoding.UTF8.GetBytes(user_password);
SHA1 sha1 = SHA1Managed.Create();
byte cryptPassword = sha1.ComputeHash(hashBytes);
- Proposed as answer by Hart ChengMicrosoft contingent staff Monday, April 24, 2017 8:53 AM
Thank you for posting here and sharing your solution.
If your issue has been resolved, please remember to close your thread by marking useful posts as answer that can be helpful for other person with same issue.
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.