NSIS 用户输入页面
NSIS User input page
所以我有一个使用下面代码的用户输入页面,并且文本正在被加密
如何将其写入文件
我现在可以将其从文件中读取到变量中以对其进行解密吗。
然后我想在屏幕上的消息框中显示解密的消息,但是 \n\n 需要在显示之前转换为 $\n 才能正确显示。
我输入的示例:(注意 Control Enter 给你下一行)
Hello World
It's a great day
解密后显示:
Hello World\n\nIt's a great day
ini 文件
[Settings]
NumFields=2
Title="Activation Code"
State=0
[Field 1]
Type=Text
Left=8
Right=-10
Top=12
Bottom=-15
flags=MULTILINE|VSCROLL
[Field 2]
Type=GroupBox
Left=0
Right=-1
Top=0
Bottom=-10
Text="Please enter in your Activation Code"
代码:
!include MUI.nsh
!include LogicLib.nsh
Page custom SetCustom ValidateCustom
Section Dummy
SectionEnd
Function SetCustom
ReserveFile ".\test.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT ".\test.ini"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY ".\test.ini"
FunctionEnd
Function ValidateCustom
!insertmacro MUI_INSTALLOPTIONS_READ $R1 ".\test.ini" "Field 1" "State"
${If} $R1 == ""
Abort # Go back to page.
${Else}
Var /GLOBAL textencryt
blowfish::encrypt $R1 "1234password"
StrCpy $textencryt
MessageBox MB_OK "Encrypted string is:$\n $textencryt"
blowfish::decrypt "1234password"
StrCpy $textencryt
MessageBox MB_OK "Decrypted string is:$\n $textencryt"
${EndIf}
FunctionEnd
新代码:(有问题)
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "test.ini" "Field 1" "State"
${If} $R1 == ""
Abort # Go back to page.
${Else}
Var /GLOBAL textencryt
blowfish::decrypt $R1 "1234password"
StrCpy $textencryt
MessageBox MB_OK "Decrypted string is:$\n $textencryt"
!insertmacro MUI_INSTALLOPTIONS_READ "test.ini" "Field 1" "HWND"
System::Call 'USER32::SendMessage(i , i ${WM_GETTEXT}, i ${NSIS_MAX_STRLEN}, t.R1)'
MessageBox MB_OK $R1
原邮件是
例子:
测试用户
代码
12个月
加密后,我尝试解密并使用查看结果
"MessageBox MB_OK "解密后的字符串是:$\n $textencryt" returns 解密后的消息,其中包含 \n\n。(示例:测试用户\n\ncode\n\12months)它应该像这样出来:
例子:
测试用户
代码
12个月
你有两个选择。
您可以使用 INSTALLOPTIONS_READ_CONVERT 辅助函数:
...
!insertmacro INSTALLOPTIONS_FUNCTION_READ_CONVERT
Function ValidateCustom
!insertmacro INSTALLOPTIONS_READ_CONVERT $R1 "test.ini" "Field 1" "State"
MessageBox MB_OK $R1
FunctionEnd
或者您可以直接从控件中读取文本:
...
!include WinMessages.nsh
Function ValidateCustom
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "test.ini" "Field 1" "HWND"
System::Call 'USER32::SendMessage(i $R1, i ${WM_GETTEXT}, i ${NSIS_MAX_STRLEN}, t.R1)'
MessageBox MB_OK $R1
FunctionEnd
所以我有一个使用下面代码的用户输入页面,并且文本正在被加密
如何将其写入文件
我现在可以将其从文件中读取到变量中以对其进行解密吗。
然后我想在屏幕上的消息框中显示解密的消息,但是 \n\n 需要在显示之前转换为 $\n 才能正确显示。
我输入的示例:(注意 Control Enter 给你下一行)
Hello World
It's a great day
解密后显示:
Hello World\n\nIt's a great day
ini 文件
[Settings]
NumFields=2
Title="Activation Code"
State=0
[Field 1]
Type=Text
Left=8
Right=-10
Top=12
Bottom=-15
flags=MULTILINE|VSCROLL
[Field 2]
Type=GroupBox
Left=0
Right=-1
Top=0
Bottom=-10
Text="Please enter in your Activation Code"
代码:
!include MUI.nsh
!include LogicLib.nsh
Page custom SetCustom ValidateCustom
Section Dummy
SectionEnd
Function SetCustom
ReserveFile ".\test.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT ".\test.ini"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY ".\test.ini"
FunctionEnd
Function ValidateCustom
!insertmacro MUI_INSTALLOPTIONS_READ $R1 ".\test.ini" "Field 1" "State"
${If} $R1 == ""
Abort # Go back to page.
${Else}
Var /GLOBAL textencryt
blowfish::encrypt $R1 "1234password"
StrCpy $textencryt
MessageBox MB_OK "Encrypted string is:$\n $textencryt"
blowfish::decrypt "1234password"
StrCpy $textencryt
MessageBox MB_OK "Decrypted string is:$\n $textencryt"
${EndIf}
FunctionEnd
新代码:(有问题)
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "test.ini" "Field 1" "State"
${If} $R1 == ""
Abort # Go back to page.
${Else}
Var /GLOBAL textencryt
blowfish::decrypt $R1 "1234password"
StrCpy $textencryt
MessageBox MB_OK "Decrypted string is:$\n $textencryt"
!insertmacro MUI_INSTALLOPTIONS_READ "test.ini" "Field 1" "HWND"
System::Call 'USER32::SendMessage(i , i ${WM_GETTEXT}, i ${NSIS_MAX_STRLEN}, t.R1)'
MessageBox MB_OK $R1
原邮件是 例子: 测试用户 代码 12个月 加密后,我尝试解密并使用查看结果 "MessageBox MB_OK "解密后的字符串是:$\n $textencryt" returns 解密后的消息,其中包含 \n\n。(示例:测试用户\n\ncode\n\12months)它应该像这样出来: 例子: 测试用户 代码 12个月
你有两个选择。
您可以使用 INSTALLOPTIONS_READ_CONVERT 辅助函数:
...
!insertmacro INSTALLOPTIONS_FUNCTION_READ_CONVERT
Function ValidateCustom
!insertmacro INSTALLOPTIONS_READ_CONVERT $R1 "test.ini" "Field 1" "State"
MessageBox MB_OK $R1
FunctionEnd
或者您可以直接从控件中读取文本:
...
!include WinMessages.nsh
Function ValidateCustom
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "test.ini" "Field 1" "HWND"
System::Call 'USER32::SendMessage(i $R1, i ${WM_GETTEXT}, i ${NSIS_MAX_STRLEN}, t.R1)'
MessageBox MB_OK $R1
FunctionEnd