如何使用InstallScript加密字符串

时间:2021-11-28 22:39:21

I'm building an installer using InstallScript MSI project. During installation I save some information to a local file. This file is created based on the user's preferences and it may contain sensitive information.

我正在使用InstallScript MSI项目构建安装程序。在安装过程中,我将一些信息保存到本地文件中。此文件是根据用户的首选项创建的,可能包含敏感信息。

I would like to encrypt this information but couldn't find any InstallScript function to handle this. I know I can have feature files encrypted, but this file is create during installation and is not a part of a specific feature.

我想加密这些信息,但找不到任何InstallScript函数来处理这个问题。我知道我可以加密功能文件,但是这个文件是在安装过程中创建的,不是特定功能的一部分。

Does anyone know of a way to encrypt strings using InstallScript?

有没有人知道使用InstallScript加密字符串的方法?

Thanks!

谢谢!

1 个解决方案

#1


1  

Like KMoraz wrote - I don't know of a builtin function for this.

就像KMoraz写的那样 - 我不知道内置函数。

For what it's worth - the way I do it is by using an external COM DLL to do the encryption/decryption for me.
You will of course need to obtain/create such a DLL to use and deploy it with the installation.
(I use pure installscript installation - not MSI)

对于它的价值 - 我这样做的方法是使用外部COM DLL为我做加密/解密。您当然需要获取/创建这样的DLL以便在安装时使用和部署它。 (我使用纯installscript安装 - 而不是MSI)

function STRING Encryption(bEncrypt,sInput)
    STRING  sEncryptionKey, sResult;
    OBJECT  oEncryption;
begin 
    try 
        // create encryption key
        sEncryptionKey = "key";

        // create COM object
        set oEncryption = CoCreateObject("Encryption");
        if (IsObject(oEncryption)) then
            // set encryption key
            oEncryption.Initialize(sEncryptionKey);
            if (bEncrypt = TRUE) then
                sResult = oEncryption.Encode(sInput);
            else    
                sResult = oEncryption.Decode(sInput);
            endif;
        endif;
        // free object
        set oEncryption = NOTHING;
    catch
        sResult = "";
    endcatch;

    return sResult;
end;

Hope this helps in any way.

希望这有助于任何方式。

#1


1  

Like KMoraz wrote - I don't know of a builtin function for this.

就像KMoraz写的那样 - 我不知道内置函数。

For what it's worth - the way I do it is by using an external COM DLL to do the encryption/decryption for me.
You will of course need to obtain/create such a DLL to use and deploy it with the installation.
(I use pure installscript installation - not MSI)

对于它的价值 - 我这样做的方法是使用外部COM DLL为我做加密/解密。您当然需要获取/创建这样的DLL以便在安装时使用和部署它。 (我使用纯installscript安装 - 而不是MSI)

function STRING Encryption(bEncrypt,sInput)
    STRING  sEncryptionKey, sResult;
    OBJECT  oEncryption;
begin 
    try 
        // create encryption key
        sEncryptionKey = "key";

        // create COM object
        set oEncryption = CoCreateObject("Encryption");
        if (IsObject(oEncryption)) then
            // set encryption key
            oEncryption.Initialize(sEncryptionKey);
            if (bEncrypt = TRUE) then
                sResult = oEncryption.Encode(sInput);
            else    
                sResult = oEncryption.Decode(sInput);
            endif;
        endif;
        // free object
        set oEncryption = NOTHING;
    catch
        sResult = "";
    endcatch;

    return sResult;
end;

Hope this helps in any way.

希望这有助于任何方式。