如何使用 InstallScript 加密字符串

发布于 2024-08-15 12:33:07 字数 230 浏览 2 评论 0原文

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

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

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

谢谢!

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.

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.

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

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆沫 2024-08-22 12:33:07

正如 KMoraz 所写 - 我不知道有什么内置函数可以实现这一点。

对于它的价值 - 我这样做的方式是使用外部 COM DLL 来为我进行加密/解密。
当然,您需要获取/创建这样的 DLL 才能在安装时使用和部署它。
(我使用纯安装脚本安装 - 不是 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;

希望这有任何帮助。

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

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)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文