我可以在IronPython中加载同一DLL的两个版本

时间:2012-08-14 22:03:34

标签: .net dll clr ironpython

我有一个同时执行加密和解密的DLL,但在客户端站点,当字符串加密后解密失败,然后发送到另一台机器以通过Web服务解密。

目前我已经测试过目标机器上的DLL可以加密和解密字符串就好了。我想做的是从BOTH机器(不同版本)中获取DLL,在IronPython脚本中加载它们,加载一个DLL,另一个DLL解密。我知道我可以将它们加载到clr中。鉴于它们因版本而异,但在此之后我如何区分它们?

以下是我现在使用单个DLL的内容:

from Some.Dll import SecurityUtils
from System.Text.Encoding import UTF8

import clr


class Codec:
def __init__(self, publicKey):
    self.decryptedBytes = None
    self.encryptedString = None
    self.publicKey = publicKey

def encrypt(self, text):
    #dir = os.path.dirname(__file__);
    #dir = os.path.join(dir, '..');
    #dir = os.path.join(dir, 'oldsystem');

    #dir = sys.path.append(dir)
    #clr.AddReference(r'Some.Dll')

    textBytes = UTF8.GetBytes(text)
    self.encryptedString = SecurityUtils.Encrypt_RSA(textBytes, self.publicKey)

def decrypt(self):
    self.decryptedBytes = SecurityUtils.Decrypt_RSA(self.encryptedString)

def getDecryptedString(self):
    return UTF8.GetString(self.decryptedBytes)

0 个答案:

没有答案