Jump to content

Case Sensitive Case Statements


dmollico
 Share

Recommended Posts

Can Autoit Tell the difference between A and a

If so, how do I do that?

I'm trying do to something like this:

Select

Case $fullpassword[$charpos] = "a"

$tempchar = "x"

Case $fullpassword[$charpos] = "A"

$tempchar = "F"

Case Else

MsgBox(0, "Error", "I don't have a clue")

Exit

EndSelect

Thanks guys!

Link to comment
Share on other sites

Here is how I get the information in. All this is above the above text in the script:

$done = 0

$fullpassword = InputBox("Encrypted Text", "Enter the encrypted_

password here")

If @error = 1 Then

MsgBox(4096,"ERROR", "Your Pressed Cancel.")

EXIT

Else

EndIf

$fullpassword = StringSplit($fullpassword, "")

$length = UBound($fullpassword)

Link to comment
Share on other sites

Slim, AWESOME! Thank you very much!

One more q, I am going to be looping that case statement untill it goes through each letter I have.

What is the best way to store the tempchar sequentially into an array at the bottom of the case statements? My guess is this:

DO

Select

Case $fullpassword[$charpos] == "a"

$tempchar = "x"

Case $fullpassword[$charpos] == "A"

$tempchar = "y"

Case Else

MsgBox(0, "Error", "I don't have a clue")

Exit

EndSelect

$final[$charpos] = $tempchar

$charpos = $charpos - 1

Until $charpos = 0

Link to comment
Share on other sites

I have no idea what the purpose is of the script.

I adjusted that little script.

If you post/attach your script, we can improve the whole script.

I'd love to.

$Password = "Iwantanewpassword"
$PassLength = StringLen($Password)

For $i = $PassLength To 1 Step -1
   $Char = StringMid($Password, $i, 1)
   $charpos = $i
   
   Select
      Case $Char == "A"
         $tempchar = "y"
      
      Case Else
        ;MsgBox(0, "Error", "I don't have a clue")
        ;Exit
         $tempchar = "x"
      
   EndSelect

   $final[$charpos] = $tempchar
Next
Link to comment
Share on other sites

Sorry, the purpose of this script is to decrypt passwords

I have it ask for the hash, then it splits the has and puts each letter of the has into it's own spot in the array, then i get the length of the array, then it is supposed to go through the select statements and when it finds the first one, stores to the tempchar variable and then at the end of the select, moves that variable into the final array and it does that untill it's gone through all the letters in the hash.

Here is pretty much the entire code, sorry I can't all the case statements in, but i figured this should be enough.

Thanks again!

$fullpassword = InputBox("Encrypted Text", "Enter the encrypted_
password here") 

If @error = 1 Then 
MsgBox(4096,"ERROR", "Your Pressed Cancel.")
EXIT

Else
EndIf

$fullpassword = StringSplit($fullpassword, "")

$length = UBound($fullpassword) 



;store the meaning of each character



;Begin working on decrypting the password


$charpos = $length - 1
$finlength = $charpos
DIM $final[$charpos]


DO

Select
    Case $fullpassword[$charpos] == "a"
    $tempchar = "x"

    Case $fullpassword[$charpos] == "A"
    $tempchar = "y"

    Case Else

        MsgBox(0, "Error", "I don't have a clue")
    Exit
EndSelect


$final[$charpos] = $tempchar
$charpos = $charpos - 1
Until $charpos = 0


; Display password


$newcharpos = 1

DO

$output = $fullpassword[$newcharpos]
MsgBox(4096,"Array Contents"," characters: " & $output)
$newcharpos = $newcharpos + 1
$finlength = $finlength -1

Until $finlength = 0
Link to comment
Share on other sites

Try (lots of stuff you were doing was just the use of For/Next

$fullpassword = InputBox("Encrypted Text", _
        "Enter the encrypted password here") 
If @error = 1 Then
    MsgBox(4096, "ERROR", "Your Pressed Cancel.")
    Exit
ElseIf $fullpassword = '' Then
    MsgBox(4096, "ERROR", "You didn't enter anything.")
    Exit
Else
    $fullpassword = wStringSplitB($fullpassword)
    Dim $final[$fullpassword[0] + 1]
EndIf
;store the meaning of each character
;Begin working on decrypting the password
For $count = $fullpassword[0] To 1 Step - 1
    Select
        Case $fullpassword[$count] == "a"
            $tempchar = "x"
        Case $fullpassword[$count] == "A"
            $tempchar = "y"
        Case Else
            MsgBox(0, "Error", "I don't have a clue")
            Exit
    EndSelect
    $final[$count] = $tempchar
Next
; Display password
For $count = 1 To $fullpassword[0]
    $output = $fullpassword[$count]
    MsgBox(4096, "Array Contents", " characters: " & $output)
Next
Func wStringSplitB($wStrSplString)
    If $wStrSplString = '' Then
        Dim $wStrSplArray[1]
        $wStrSplArray[0] = -1
    Else
        Dim $wStrSplArray[StringLen($wStrSplString) + 1]
        $wStrSplArray[0] = StringLen($wStrSplString)
        For $wStrSplCount = 1 To StringLen($wStrSplString)
            $wStrSplArray[$wStrSplCount] = StringLeft($wStrSplString, 1)
            $wStrSplString = StringTrimLeft($wStrSplString, 1)
        Next
    EndIf
    Return $wStrSplArray
EndFunc  ;==>wStringSplitB

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Link to comment
Share on other sites

Just if your Select-Case is growing to big

; Here is the list of original chars
$AllAllowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
; Here is the list of encrypted chars, Watch for same length!!!
$TheCryptChars = "zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA"

$fullpassword = InputBox("Encrypted Text", _
      "Enter the encrypted password here")
If @error = 1 Then
   MsgBox(4096, "ERROR", "Your Pressed Cancel.")
   Exit
ElseIf $fullpassword = '' Then
   MsgBox(4096, "ERROR", "You didn't enter anything.")
   Exit
EndIf

$cryptpassword = StringCrypt($fullpassword, $AllAllowedChars, $TheCryptChars)
$decryptpassword = StringCrypt($cryptpassword, $TheCryptChars, $AllAllowedChars)
; Display result
MsgBox(4096, "Password", $fullpassword & " <- entered" & @CR & $cryptpassword & " <- encrypted" & @CR & $decryptpassword & " <- same as entered?")
Exit

;crypt the string by using two strings as combined lookup table
Func StringCrypt($TheString, $SrcList, $DstList)
   $FinalString = ""
   $strLen = StringLen($TheString)
   For $count = $strLen To 1 Step - 1
      $Pos = StringInStr($SrcList, StringMid($TheString, $count, 1), 1)
      If $Pos = 0 Then
         MsgBox(0, "Error", "I don't have a clue how to handle char " & StringMid($TheString, $count, 1))
         Exit
      EndIf
      $FinalString = $FinalString & StringMid($DstList, $Pos, 1)
   Next      
   Return $FinalString
EndFunc  ;==>StringCrypt
Link to comment
Share on other sites

Kanumi -

These are the characters I need in the hash:

$AllAllowedChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`~!@#$%^&*()_-+=[{]}\|;:'",<.>/?"

It won't let me store all that to the variable...any ideas?

<{POST_SNAPBACK}>

The problem is with the quotation mark within the string. Replace the quote with two quotes and it will work.

Phillip

Link to comment
Share on other sites

  • 2 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...