Jump to content
Sign in to follow this  
DavidTunnell

Error checking the _StringEncrypt function

Recommended Posts

DavidTunnell

I am using _StringEncrypt to decrypt a password that is used in a script with the use of a passcode:

Global $IwpPassword = "D54A7D0E565AEA6251EF68376CD13577C8A89201F31D9946B5A551C9CF646506BCB0EF8BD74847433D7024C9BC80E021E835A67F4D9F2DE4ED59F8AD856A42D3"

$UserPassCode = InputBox("Passcode Needed", "What is the passcode?")
$IwpPassword = _StringEncrypt(0, $IwpPassword, $UserPassCode, 3)

How can I provide error checking? If the user puts in the wrong passcode accoding to the documentation this should be the result: Blank string and @error = 1

But this doesn't work:

If ($IwpPassword <> "") Then
;code
EndIf

It appears to always input some kind of string. Without defeating the purpose by checking the result against the password, how can I tell if the output is wrong and thus exit the script.

 

Share this post


Link to post
Share on other sites
Danyfirex

Hi, Did you try this?:

If Not($IwpPassword == "") Then

EndIf

I really do not understand that you want to check.

Edited by Danyfirex

Share this post


Link to post
Share on other sites
michaelslamet

Hello David,

Something like this?

#include<string.au3>

Global $IwpPassword = "D54A7D0E565AEA6251EF68376CD13577C8A89201F31D9946B5A551C9CF646506BCB0EF8BD74847433D7024C9BC80E021E835A67F4D9F2DE4ED59F8AD856A42D3"

$UserPassCode = InputBox("Passcode Needed", "What is the passcode?", "", "*")
$IwpPassword = _StringEncrypt(0, $IwpPassword, $UserPassCode, 3)
If StringCompare($UserPassCode, $IwpPassword, 1) <> 0 Then            ; use StringCompare to check case sensitive
    MsgBox(0,"Incorrect","Your password is incorrect")
Else
    MsgBox(0,"Correct","Your password is correct")
EndIf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×