【问题标题】:How to encode string in NSIS to UTF-16LE format?如何将 NSIS 中的字符串编码为 UTF-16LE 格式?
【发布时间】:2019-09-23 10:26:55
【问题描述】:

您好,我正在尝试在 Python 中为 NSIS 安装程序复制此代码。

m = hashlib.md5("C:\PROGRAM FILES\My Program".encode('utf-16LE'))

它基本上对字符串进行编码,然后对其应用 MD5 哈希。我找到了 NSIS 的 MD5 哈希插件。但是,我仍然不知道如何将 $0 中的字符串转换为 utf-16LE 格式。

谢谢

【问题讨论】:

  • Unicode 或 Ansi 安装程序?

标签: encoding nsis utf-16le


【解决方案1】:

如果您正在构建 Unicode 安装程序,您可以使用 Crypto plug-in 并直接输入字符串:

Unicode True
...
Section
Crypto::HashUTF16LE MD5 "The quick brown fox jumps over the lazy dog"
Pop $0
DetailPrint $0 ; B0986AE6EE1EEFEE8A4A399090126837
SectionEnd

ANSI 安装程序必须将内容写入文件并对文件进行哈希处理:

Section
InitPluginsDir
StrCpy $1 "The quick brown fox jumps over the lazy dog"
StrLen $3 $1
IntOp $3 $3 * 2 ; UTF-16 is 2 bytes per code-unit
FileOpen $2 "$PluginsDir\Temp.txt" w
System::Call 'KERNEL32::WriteFile(pr2,wr1,ir3,*i,p0)' ; This converts the string for us
FileClose $2
Crypto::HashFile MD5 "$PluginsDir\Temp.txt"
Pop $0
DetailPrint $0
SectionEnd

【讨论】:

    猜你喜欢
    • 2017-02-28
    • 2020-11-07
    • 1970-01-01
    • 2014-09-12
    • 1970-01-01
    • 2017-02-07
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    相关资源
    最近更新 更多