There is a method that accepts a password and returns it already hashed in MD5. At first, I didn’t use SecureString but simply a string into which I wrote the Password taken from the controller and there were no problems. Now I read that with this approach, the string is stored in the processor's memory, so it is recommended to use SecurePassword and transfer to the server like this. Actually now because of this error occurs:
Error CS1503 Argument 1: Cannot convert from "SecureString" to "char []".
internal static string GetHash(System.Security.SecureString passHASH) //тут { MD5 md5Hasher = MD5.Create(); byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(passHASH)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } return sBuilder.ToString(); } You can certainly write like this
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(passHASH.ToString())); But will this not fix the use of SecureString ?
SecureStringsimpleSecureString.ToString(). - MihailPwSecureStringwhen translatingpassHASHto a regularstring? becauseSecureStringin MD5 is not hashed. - SergeyPasswordBoxwhich has 2 properties -PasswordandSecurePassword. I want to understand which option is better and if the second is how to get a hash fromSecurePassword? - Sergey