Jump to content
Sign in to follow this  
E1M1

How to make my script work with 3 and more characters?

Recommended Posts

E1M1

This script works with 1 char and if char is õ then it starts from 0 but this time it uses 2 chars (just show u how it goes õ > 00 > 01 > 02.. and it ends with õõ) now how I can make it dynamically add new characters? So if $i = 220 string would be 000 and if that number is 231 string should be 00a and so how, how I could do it?

Dim $var[74]
$var[0] = 0
$var[1] = 1
$var[2] = 2
$var[3] = 3
$var[4] = 4
$var[5] = 5
$var[6] = 6
$var[7] = 7
$var[8] = 8
$var[9] = 9
$var[10] = "A"
$var[11] = "B"
$var[12] = "C"
$var[13] = "D"
$var[14] = "E"
$var[15] = "F"
$var[16] = "G"
$var[17] = "H"
$var[18] = "I"
$var[19] = "J"
$var[20] = "K"
$var[21] = "L"
$var[22] = "M"
$var[23] = "N"
$var[24] = "O"
$var[25] = "P"
$var[26] = "Q"
$var[27] = "R"
$var[28] = "S"
$var[29] = "Š"
$var[30] = "Z"
$var[31] = "Ž"
$var[32] = "T"
$var[33] = "U"
$var[34] = "V"
$var[35] = "W"
$var[36] = "X"
$var[37] = "Y"
$var[38] = "Ä"
$var[39] = "Ö"
$var[40] = "Ü"
$var[41] = "Õ"
$var[42] = "a"
$var[43] = "b"
$var[44] = "c"
$var[45] = "d"
$var[46] = "e"
$var[47] = "f"
$var[48] = "g"
$var[49] = "h"
$var[50] = "i"
$var[51] = "j"
$var[52] = "k"
$var[53] = "l"
$var[54] = "m"
$var[55] = "n"
$var[56] = "o"
$var[57] = "p"
$var[58] = "q"
$var[59] = "r"
$var[60] = "s"
$var[61] = "š"
$var[62] = "z"
$var[63] = "ž"
$var[64] = "t"
$var[65] = "u"
$var[66] = "v"
$var[67] = "w"
$var[68] = "x"
$var[69] = "y"
$var[70] = "ä"
$var[71] = "ö"
$var[72] = "ü"
$var[73] = "õ"
$i = 1
While 1
    $i+=1
    ToolTip(_ToString($i),0,0)
    sleep(20)
WEnd


Func _ToString($int)
    $str = ""
    If $int > 73 Then
;~      For $n = 0 To $int - 73
;~ MsgBox(0,($int - 73),$int)

;~ $int = Int($int/73) -1
;~ MsgBox(0,Int($int/73) -1,$int - ((Int($int/73))*73))

            $str &= $var[Int($int/73) -1]
;~      Next
    EndIf
    $str &= $var[$int - ((Int($int/73))*73)]
Return $str
EndFunc

edited

Share this post


Link to post
Share on other sites
spudw2k

I'm sure there's a more programmatic way to do this, but here's an easy way.

edit: Nevermind, I didn't understand the OP....still don't.

Edited by spudw2k

Share this post


Link to post
Share on other sites
E1M1

I want just generate 1-st 1000 possible combinations of these chars I declared in alphabetical order

it should go like

1

2

3

...

a

b

c

...

01

02

03

...

0a

0b

0c

...

11

12

13

...

1a

1b

1c

...

and so on until $i = 1000

I have tried about 50 times, still no ideas, just buggy code

Func _ToString($int)
    $str = ""
    $temp = ""
;~  If $int > 73 Then
;~      For $n = 1 To Int ($int / 73)
;~      For $n = 1 To 1

;~ $int = Int($int/73) -1
;~ MsgBox(0,Int($int/73) -1,$int - ((Int($int/73))*73))
;~          $temp = Int($int / 73) - 1
;~          MsgBox(0,($int - 73),$int)
;~          MsgBox(0,$temp ,$int)
;~          $str &= $var[$temp]
;~          $str &= $var[$int - ((Int($int/73))*73)]
;~      Next
;~  EndIf
;~  $str &= $var[$int - ((Int($int/73))*73)]

While StringLen($str) < Int ($int / 73)
    $str &= $var[$int - (Int($int / 73)*73)]
WEnd
Return $str
EndFunc
Edited by E1M1

edited

Share this post


Link to post
Share on other sites
PsaltyDS

The problem here is the number of combinations. Take a three digit decimal number. 10^3 = 1000 possible (including 0). Here you have 74 "digits", so it's 74^3 = 405224 possible combinations of those 74 characters. If you really must see them all, it would look like this:

Global $avSrc = StringSplit("0123456789ABCDEFGHIJKLMNOPQRSŠZŽTUVWXYÄÖÜÕabcdefghijklmnopqrsšzžtuvwxyäöüõ", "")

For $c = 0 To $avSrc[0]
    For $b = 0 To $avSrc[0]
        For $a = 1 To $avSrc[0]
            $sText = ""
            If $c Then $sText &= $avSrc[$c]
            If $b Then $sText &= $avSrc[$b]
            $sText &= $avSrc[$a]

            $iIndex = $a + ($b * $avSrc[0]) + ($c * ($avSrc[0] ^ 2))

            ConsoleWrite($iIndex & " = " & $sText & @LF)
        Next
    Next
Next

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
memoryoverflow

If it's that what you're looking for, I have a 1-line-loop:

Dim $var = StringSplit('0123456789ABCDEFGHIJKLMNOPQRSŠZŽTUVWXYÄÖÜÕabcdefghijklmnopqrsšzžtuvwxyäöüõ', '')
$l = $var[0]
$var[0] = ''

For $i = 1 To $l^3 + $l^2 + $l
    ConsoleWrite(StringFormat('%6d: ', $i) & $var[Int(($i - ($i > $l ^ 2)) / ($l ^ 2 + $l))] & $var[($i > $l ^ 2) + Mod(Int(($i - ($i > $l)) / ($l + ($i < $l))) - ($i > $l ^ 2), $l + 1 - ($i > $l ^ 2))] & $var[($i > $l) + Mod($i - ($i > $l), $l + 1 - ($i > $l))] & @CRLF)
Next
:) Just for fun - not exactly sensible (but it does the job). Edited by memoryoverflow

(The signature is placed on the back of this page to not disturb the flow of the thread.)

Share this post


Link to post
Share on other sites
E1M1

thanx alot, Is it possible to speed it up?


edited

Share this post


Link to post
Share on other sites
PsaltyDS

thanx alot, Is it possible to speed it up?

Well, if you just want to know the nth result is there is no need to create a list. Think of it this way: You have 74 symbols and you want to represent a decimal (base10) number as a tetraheptimal (base74) number. So the script to do that takes a decimal integer input and converts it to a base74 number:
Global $avSrc = StringSplit("0123456789ABCDEFGHIJKLMNOPQRSŠZŽTUVWXYÄÖÜÕabcdefghijklmnopqrsšzžtuvwxyäöüõ", "")
Global $sInput, $iInput, $iIndex, $sText

While 1
    $sInput = InputBox("Base " & $avSrc[0] & " Converter", "Enter a decimal positive integer (n >= 0): ")
    If @error Then ExitLoop
    $iInput = Int($sInput)
    If (StringIsInt($sInput) = 0) Or ($iInput < 0) Then
        MsgBox(16, "Error", "Input error: integer >= 0 required")
        ContinueLoop
    EndIf

    $sText = ""
    While 1
        $iIndex = Mod($iInput, $avSrc[0])
        $sText = $avSrc[$iIndex + 1] & $sText  ; numbers are 0-based, but array of symbols is 1-based
        $iInput = Floor($iInput / $avSrc[0])
        If $iInput = 0 Then ExitLoop
    WEnd

    MsgBox(64, "Base " & $avSrc[0] & " Converter", $sInput & " (base10) = " & $sText & " (base" & $avSrc[0] & ")")
WEnd

This numeric conversion will be much faster than trying to create a complete list and look up the symbols.

You can change the string in the first line of the script above to any list of symbols of any length, and it should still work. For example if you put only 0 thru 9 and A thru F it should become a decimal to hexadecimal converter.

In the OP you said 220 = 000, which is not numeric notation and ignores a lot of two character combinations without explanation. This system also would not produce 00, because that is also the same as 0.

The first three character symbol in any number base comes at (base ^ 2). For decimal that's 10^2 = 100 is the first three digit number (the 101st symbol, counting 0), and for this base74 system it would be 74^2 = 5476, or the 5477th symbol. I'm assuming that was just a mistake in your description.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
E1M1

PsaltyDS ur script dont display char or har combination for me.


edited

Share this post


Link to post
Share on other sites
PsaltyDS

PsaltyDS ur script dont display char or har combination for me.

What is "char or har combination"? What did you input, and what did you expect for output?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
E1M1

i expected output like memoryoverflow's script has but I want just make same thing faster.


edited

Share this post


Link to post
Share on other sites
memoryoverflow

Then do it (other than in my joke) in Psalty's sensible way (nested loops), just put $var[0] to '' to get the leading '', i.e. nothing, like I've done.

Just seeing that this displays a bit unclear: '' is not a doublequote, it's an empty string.

Edited by memoryoverflow

(The signature is placed on the back of this page to not disturb the flow of the thread.)

Share this post


Link to post
Share on other sites
PsaltyDS

i expected output like memoryoverflow's script has but I want just make same thing faster.

Maybe like this (limit to first 1000 combinations):
Global $avSrc = StringSplit("0123456789ABCDEFGHIJKLMNOPQRSŠZŽTUVWXYÄÖÜÕabcdefghijklmnopqrsšzžtuvwxyäöüõ", "")
Global $iLimit = 1000

For $c = 0 To $avSrc[0]
    For $b = 0 To $avSrc[0]
        For $a = 1 To $avSrc[0]
            $sText = ""
            If $c Then $sText &= $avSrc[$c]
            If $b Then $sText &= $avSrc[$b]
            $sText &= $avSrc[$a]
            $iIndex = $a + ($b * $avSrc[0]) + ($c * ($avSrc[0] ^ 2))
            ConsoleWrite($iIndex & " = " & $sText & @LF)
            If $iIndex >= $iLimit Then ExitLoop 3
        Next
    Next
Next

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
E1M1

what's wrong here

Dim $var = StringSplit('0123456789ABCDEFGHIJKLMNOPQRSŠZŽTUVWXYÄÖÜÕabcdefghijklmnopqrsšzžtuvwxyäöüõ', '')
$l = $var[0]
$var[0] = ''
For $i = $l^4 To $l^8 + $l^7 + $l^6 + $l^5 + $l^4 + $l^3 + $l^2 + $l
;~ For $i = 1 To 100000
$text = $var[Int(($i - ($i > $l ^ 2)) / ($l ^ 2 + $l))] & $var[($i > $l ^ 2) + Mod(Int(($i - ($i > $l)) / ($l + ($i < $l))) - ($i > $l ^ 2), $l + 1 - ($i > $l ^ 2))] & $var[($i > $l) + Mod($i - ($i > $l), $l + 1 - ($i > $l))] & @CRLF
;~     ToolTip($text,0,0)
Next

error

C:\Documents and Settings\rain\My Documents\dict.au3 (30) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$text = $var[Int(($i - ($i > $l ^ 2)) / ($l ^ 2 + $l))] & $var[($i > $l ^ 2) + Mod(Int(($i - ($i > $l)) / ($l + ($i < $l))) - ($i > $l ^ 2), $l + 1 - ($i > $l ^ 2))] & $var[($i > $l) + Mod($i - ($i > $l), $l + 1 - ($i > $l))] & @CRLF
$text = ^ ERROR

How to fix it?


edited

Share this post


Link to post
Share on other sites
memoryoverflow

I think I introduced a slight typo when copying it from SciTE into the post and made a final adjustment to save even a line more.

Anyway, this was meant as a joke, it's not reasonable to do it in 1 loop, needs way more calulations at run time and slows it down.

As said, use nested loops, it's easy.

If you still have difficulties, I might post it for you. But as a prerequiste you'd need to tell for what it's good. If you want to use something like that for a brute force password breaker: there're better ways, but I'd never support such a thing.


(The signature is placed on the back of this page to not disturb the flow of the thread.)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.