Skip to content
⌘ NSIS Forum Archive

Manufacture Random word

2 posts

Anders#
How about a little more information? Does it have to be cryptographically secure? Any invalid characters? You have been here so long that you should know better by now! If the quality of your questions does not improve I will start ignoring you.

This should get you started:
retry:
System::Call kernel32::GetTickCount()i.r0
IntOp $0 $0 & 127
# TODO: Check printable ASCII range and maybe retry?
IntFmt $0 "%c" $0
# $0 now contains a character
(I'm on a tablet right now and did not verify that this code works)

Edit:

Here is one for A-Z:
!include LogicLib.nsh
StrCpy $1 ""
${For} $2 1 10
    retry:
    System::Call ADVAPI32::SystemFunction036(*i.r0,i4) ; WinXP+
    IntOp $0 $0 & 127
    ${IfThen} $0 < 65 ${|} Goto retry ${|}
    ${IfThen} $0 > 90 ${|} Goto retry ${|}
    IntFmt $0 "%c" $0
    StrCpy $1 $1$0
    ${Next}
DetailPrint $1