Ask coding questions

← Back to all posts
Hashing password

I found some code online to hash passwords and I have an annoying error I need to fix, it says an object reference is required but when I do it it comes but with an error still. The entire code is

please help

Answered by Kai_Justice [earned 5 cycles]
View Answer

Change line 16 to: public static string ComputeHash(byte[] bytesToHash, byte[] salt).
Since main is a static function and does not have a reference to the MainClass object you'll have to make any functions you want to use in it static so they can be referenced without creating an object. I don't use C# so this is just what I picked up from using other object oriented languages.


@Kai_Justice thanks so much! it works. Would you be able to help with login, I am thinking of having the user enter their username and password and hashing and salting the password to see if it's there, but I need to group the data