[Python.NET] Need help in converting function of .net to python

NicKz 👫 vs.bhadauriya at live.com
Tue May 22 08:32:45 EDT 2018


Hi All,
I hope all of you are doing well in your life.

I want to convert this .net function in python


private static string decrypt(string enctxt)

{

  string dectext = "";

  string encryptKey = "HECT17IPWORI1702";

  byte[] encArr = Convert.FromBase64String(enctxt);

  using (Aes aesObj = Aes.Create())

{

Rfc2898DeriveBytes objRfc = new Rfc2898DeriveBytes(encryptKey,

 new Byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });

aesObj.Key = objRfc.GetBytes(32);

aesObj.IV = objRfc.GetBytes(16);

  using (MemoryStream ms = new MemoryStream())

{

  using (CryptoStream cs = new CryptoStream(ms, aesObj.CreateDecryptor(), CryptoStreamMode.Write))

{

cs.Write(encArr, 0, encArr.Length);

cs.Close();

}

dectext = Encoding.Unicode.GetString(ms.ToArray());

}

}

  return dectext;

}

Please guide me how to convert it into python.

Regards
Nick

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20180522/cf1066f8/attachment-0001.html>


More information about the PythonDotNet mailing list