Decrypting in Python an string encrypted using .NET

后端 未结 2 1673
孤独总比滥情好
孤独总比滥情好 2021-02-04 13:46

I am trying to encrypt a string using C# and decrypt it using Python. The encryption/decryption part works as expected (i.e. I am able to decrypt the string I originally encrypt

2条回答
  •  北海茫月
    2021-02-04 14:12

     def decrypted(self) -> str:
        _pwd = base64.b64decode(self._key)
        _salt = base64.b64decode(self._salt)
        _aes = Crypto.Cipher.AES.new(_pwd, Crypto.Cipher.AES.MODE_CBC, _salt)
        _text = base64.b64decode(self._encrypted_str)
        _decode = _aes.decrypt(_text).decode('utf-16')
        _regex = '[a-zA-Z0-9 +-,\/ ]+'
        return re.findall(_regex, _decode)
    

    is using regex

提交回复
热议问题