Generating base64 encoded md5 in C# and Python -


i trying convert python code c# language while converting have partially achieved target using simple string e.g "abc" in both languages , generating same encoded string stuck json object here python code .

python

import base64 , hashlib , hmac , json , httplib , socket , re , email,ssl,os time import strptime , mktime , timezone , time , gmtime , strftime , daylight    h=hashlib.new ('md5') h.update(json.dumps({"username":"sym","password":"123"})) pprint.pprint(h.digest())  pprint.pprint(base64 . b64encode(h.digest())) 

c#

    using newtonsoft.json;     using newtonsoft.json.linq;     using system;     using system.collections.generic;     using system.collections.specialized;     using system.componentmodel;     using system.data;     using system.drawing;     using system.linq;     using system.net;     using system.net.security;     using system.security.cryptography;     using system.security.cryptography.x509certificates;     using system.text;     using system.threading.tasks;     using system.windows.forms;     public partial class main : form     {       static string getmd5hash(md5 md5hash, string input)         {          credentials cred = new credentials();                 cred.username = "sym";                 cred.password = "123";                 string output = jsonconvert.serializeobject(cred); byte[] data = md5hash.computehash(encoding.utf8.getbytes(output));  string s  = convert.tobase64string(data); return s ;          } } 


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -