c# - How to hash file (MD5, SHA..v.v..) in UWP -


i'm coding universal app, how can hash file md5 or sha algorithm ?

i searched, found this: system.security.cryptography, it's not available in project.

i'm using visual studio 2015.

in uwp, windows.security.cryptography namespace , windows.security.cryptography.core namespace.

in cryptographicbuffer class there sample showing how use class.

here demo getting md5 hash:

private string stralgnameused;  public string getmd5hash(string strmsg) {     string stralgname = hashalgorithmnames.md5;     ibuffer buffutf8msg = cryptographicbuffer.convertstringtobinary(strmsg, binarystringencoding.utf8);      hashalgorithmprovider objalgprov = hashalgorithmprovider.openalgorithm(stralgname);     stralgnameused = objalgprov.algorithmname;      ibuffer buffhash = objalgprov.hashdata(buffutf8msg);      if (buffhash.length != objalgprov.hashlength)     {         throw new exception("there error creating hash");     }      string hex = cryptographicbuffer.encodetohexstring(buffhash);      return hex; } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -