c# - SHA256.Create() always returns null -


whenever use sha256.create() method returns null value. here method have encrypting password ...

private string encryptpassword(string password) {     sha256 sha = sha256.create(password);     return bitconverter.tostring(sha.hash); } 

the debugger shows variable sha null. have tried putting in own method in controller still system.nullreferenceexception

public string index() {     return bitconverter.tostring(sha256.create("hello world").hash); } 

i lost. there doing wrong?

yes, create() isn't meant message, specifies sha256 implementation.

i suspect want use implementation class sha256managed instead.

http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256managed.aspx

example:

using (var sha256 = new sha256managed()) {     byte[] raw = encoding.default.getbytes(password);     return sha256.computehash(raw); } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -