OverviewExamples
-- Calculate the MD5 message digest for the user's name and display it in a message
strName = Dialog.Input("", "What is your name?", "", MB_ICONQUESTION);
strDigitalSignature = Crypto.MD5DigestFromString(strName);
Dialog.Message("The digital signature for your name is:",strDigitalSignature);
Prompts for the user's name and then generates the MD5 message digest for it and shows it in a dialog message.
--[[ note: our app allows the user to password-protect it. If the user
chose to enable password-protection, they were prompted for
a password, we appended a suffix to it (to help prevent
dictionary attacks), and the MD5 digest for the resulting
password + suffix was stored in the Registry.]]
--[[ get the digest that was stored in the Registry at HKEY_CURRENT_USER\Software\SuperDooperApp
note: this was calculated when the user supplied the password,
before it was stored ]]
reg_md5 = Registry.GetValue(HKEY_CURRENT_USER, "Software\\SuperDooperApp", "password")
-- the value only exists when the app is password-protected
if reg_md5 ~= "" then
--[[ ask the user for the password they supplied when they enabled
the password protection feature ]]
pw = Dialog.Input("", "Please enter your password:");
--[[ we added "!$" to their password before it was stored,
to help make the user's password safe from dictionary attacks ]]
pw = pw .. "!$"
-- calculate the MD5 message digest for the password + suffix
pw_md5 = Crypto.MD5DigestFromString(pw);
-- exit the app if the password digests don't match
if pw_md5 ~= reg_md5 then
Dialog.Message("", "Sorry, invalid password!");
Application.Exit();
end
end
Given that the MD5 message digest for a password was previously stored in the Registry, a user is prompted for the password and it is compared to the current password input from the user. If the message digests do not match, the application exits.
See also: Related Actions