Aceguy Posted February 25, 2009 Posted February 25, 2009 (edited) this little script helps me generate an array $alpha (a-z 0-9) jumble it up and create $beta array. how can i use stringreg..... to substitute the chr(s) in $string with the $beta Array..... hope this makes sense..... O.o expandcollapse popup#include<array.au3> $string="24680 this is a password i would like to encrypt 13579" dim $alpha[63] for $e=48 to 57;0-9; 10chrs $alpha[$e-47]=$e ConsoleWrite(chr($alpha[$e-47])&@Lf) Next for $c=65 to 90;A-Z; 26chrs $alpha[$c-54]=$c ConsoleWrite(chr($alpha[$c-54])&@Lf) Next for $d=97 to 122;a-z; 26 chrs $alpha[$d-60]=$d ConsoleWrite(chr($alpha[$d-60])&@Lf) next dim $beta[63] _ArrayDisplay($alpha,"Aplha") $_ct=1 Do if UBound($alpha)-1 >2 Then $rnd=Random(1,ubound($alpha)-1,1) Else $rnd=1 EndIf $beta[$_ct]=$alpha[$rnd] ConsoleWrite("Ct "&$_ct&" Rnd ="&$rnd&" ubound "&UBound($alpha)-1&" aplharnd "&$alpha[$rnd]&@Lf) _ArrayDelete($alpha,$rnd) $_ct+=1 until $_ct=63 for $ct=1 to 62 ConsoleWrite($ct& "<=ct chr> "&chr($beta[$ct])&@Lf) Next ;stringreg................... this is the part i cannot do Edited February 27, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
jvanegmond Posted February 25, 2009 Posted February 25, 2009 I am pretty sure you can ran into this problem: string: ab a=>b b=>c then result is this: ab a=>b bb b=>c cc Anyway, you're not making much sense. Try to explain it on a more basic level. Part of the output is : 1<=ct chr> 0 2<=ct chr> t 3<=ct chr> N 4<=ct chr> c 5<=ct chr> b 6<=ct chr> B 7<=ct chr> w 8<=ct chr> D 9<=ct chr> o 10<=ct chr> d What does this mean? github.com/jvanegmond
Aceguy Posted February 26, 2009 Author Posted February 26, 2009 1<=ct chr> 02<=ct chr> t3<=ct chr> N4<=ct chr> c5<=ct chr> b6<=ct chr> B7<=ct chr> w8<=ct chr> D9<=ct chr> o10<=ct chr> dWhat does this mean?This is just for debugging..... to see how the array develops.....the question is.....using stringregexprepl how do i substitute a letter r for a letter zE for a letter hj for a letter qect..... [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
jvanegmond Posted February 26, 2009 Posted February 26, 2009 If that is your custom, why all the blah blah about arrays and encryption? Here: StringRegExpReplace("aabbcc","a","d") returns ddbbcc Or you could just as well do this: StringReplace("aabbcc","a","d") StringRegExp is only for more complicated matches. github.com/jvanegmond
Aceguy Posted February 26, 2009 Author Posted February 26, 2009 can it do multiple replacements.... ie...a for d, w for g, t for b .... [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
jvanegmond Posted February 26, 2009 Posted February 26, 2009 can it do multiple replacements....ie...a for d, w for g, t for b ....It can if you put it in a loop .... ¬.¬ github.com/jvanegmond
Aceguy Posted February 26, 2009 Author Posted February 26, 2009 (edited) this is the code that i want but i have a problem... expandcollapse popup#include<array.au3> $string="24680 this is a password i would like to encrypt 13579" dim $alpha[63] dim $beta[63] Dim $charlie[63] for $e=48 to 57;0-9; 10chrs $alpha[$e-47]=$e $charlie[$e-47]=$e Next for $c=65 to 90;A-Z; 26chrs $alpha[$c-54]=$c $charlie[$c-54]=$c Next for $d=97 to 122;a-z; 26 chrs $alpha[$d-60]=$d $charlie[$d-60]=$d next $_ct=1 Do if UBound($alpha)-1 >2 Then $rnd=Random(1,ubound($alpha)-1,1) Else $rnd=1 EndIf $beta[$_ct]=$alpha[$rnd] ;ConsoleWrite("Ct "&$_ct&" Rnd ="&$rnd&" ubound "&UBound($alpha)-1&" aplharnd "&$alpha[$rnd]&@Lf) _ArrayDelete($alpha,$rnd) $_ct+=1 until $_ct=63 $ss=StringSplit($string,"") $new="" For $count=1 To $ss[0] If $ss[$count]<> " " Then For $ct2=1 To 62 If $ss[$count] = Chr($beta[$ct2]) Then ;ConsoleWrite("$ss[count] "&$ss[$count]&" Chr($beta[$ct2]) "&Chr($beta[$ct2])&@LF) $new&=Chr($charlie[$ct2]) EndIf next Else $new&=" " EndIf Next ConsoleWrite("old string = "&$string&@LF) ConsoleWrite("new string = "&$new&@LF)oÝ÷ Ù»¶©®åzh¡j÷¢±«¢+Ø%¥ÀÌØíÍÍlÀÌØí½Õ¹Ñtô ¡È ÀÌØíÑlÀÌØíÐÉt¤Ñ¡¸ it will return C = c ..... but C = c is not case sensitive... anyone has any ideas. so....why does that return a match.... when chr(65) should = "A" not "a" If Chr(65)="a" Then MsgBox(0,"","Match",0) Edited February 26, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
Authenticity Posted February 26, 2009 Posted February 26, 2009 Use == instead. if $ss[$count] == Chr($beta[$ct2]) then
Aceguy Posted February 26, 2009 Author Posted February 26, 2009 Great Authenticity... works a treat... THANK YOU [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
jvanegmond Posted February 26, 2009 Posted February 26, 2009 You should never use a single = character to compare anything. Do as the C family does it, and use double = chars. If you want to compare strings case insensitive use StringLower .. github.com/jvanegmond
Aceguy Posted February 26, 2009 Author Posted February 26, 2009 Works.... thanks all expandcollapse popup#include<array.au3> $string="24680 this is a password I would like to Encrypt 13579" dim $alpha[63] dim $beta[63] Dim $charlie[63] for $e=48 to 57;0-9; 10chrs $alpha[$e-47]=$e $charlie[$e-47]=$e Next for $c=65 to 90;A-Z; 26chrs $alpha[$c-54]=$c $charlie[$c-54]=$c Next for $d=97 to 122;a-z; 26 chrs $alpha[$d-60]=$d $charlie[$d-60]=$d next $_ct=1 Do if UBound($alpha)-1 >2 Then $rnd=Random(1,ubound($alpha)-1,1) Else $rnd=1 EndIf $beta[$_ct]=$alpha[$rnd] ;ConsoleWrite("Ct "&$_ct&" Rnd ="&$rnd&" ubound "&UBound($alpha)-1&" aplharnd "&$alpha[$rnd]&@Lf) _ArrayDelete($alpha,$rnd) $_ct+=1 until $_ct=63 $ss=StringSplit($string,"") $new="" For $count=1 To $ss[0] If $ss[$count]<> " " Then For $ct2=1 To 62 If $ss[$count] == Chr($beta[$ct2]) Then ;ConsoleWrite("$ss[count] "&$ss[$count]&" Chr($beta[$ct2]) "&Chr($beta[$ct2])&@LF) $new&=Chr($charlie[$ct2]) EndIf next Else $new&=" " EndIf Next ConsoleWrite("old string = "&$string&@LF) ConsoleWrite("new string = "&$new&@LF) _ArraySort($beta) $ss=StringSplit($string,"") $new="" For $count=1 To $ss[0] If $ss[$count]<> " " Then For $ct2=1 To 62 If $ss[$count] == Chr($beta[$ct2]) Then ;ConsoleWrite("$ss[count] "&$ss[$count]&" Chr($beta[$ct2]) "&Chr($beta[$ct2])&@LF) $new&=Chr($charlie[$ct2]) EndIf next Else $new&=" " EndIf Next ConsoleWrite("converted string = "&$new&@LF) [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
Aceguy Posted February 27, 2009 Author Posted February 27, 2009 (edited) the reason behind this is that i am going to make a script that uses this code to save all my wifes and my passswords and bank details on my pc... in a nice and easy combobox... and did not want to save it in raw format..... hence the encryption..... so my prog will save the new array.....(mixed up alphabet) in one file,.... stored in the depths of my pc and one that contains the encrypted passwords.... my code will also re-manipulate the array for furthur emcrption... i.e. will add an additional number to it........ Am i trying to re-invent the wheel, yes, probably.... but it will be my wheel. and i think it will be an (near) uncrackable code.? Edited February 27, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
jvanegmond Posted February 27, 2009 Posted February 27, 2009 Am i trying to re-invent the wheel, yes, probably.... but it will be my wheel. and i think it will be an (near) uncrackable code.?Rather than rely on yourself to invent a new encryption and assume it is unbreakable, use the latest standard for encryption.I have made the same thing as you did and I have used the Rijndael algorithm for encryption. github.com/jvanegmond
PsaltyDS Posted February 27, 2009 Posted February 27, 2009 the reason behind this is that i am going to make a script that uses this code to save all my wifes and my passswords and bank details on my pc... in a nice and easy combobox...and did not want to save it in raw format.....hence the encryption.....so my prog will save the new array.....(mixed up alphabet) in one file,.... stored in the depths of my pc and one that contains the encrypted passwords.... my code will also re-manipulate the array for furthur emcrption... i.e. will add an additional number to it........Am i trying to re-invent the wheel, yes, probably.... but it will be my wheel. and i think it will be an (near) uncrackable code.?You are unlikely to code anything in AutoIt, which requires weakly encrypted plain text source be available to the interpreter, that can match the security of tools like PasswordSafe and the Blowfish algorithm it uses. 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
Aceguy Posted February 27, 2009 Author Posted February 27, 2009 Damn, i feel like a noob.... lol [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
jvanegmond Posted February 27, 2009 Posted February 27, 2009 Damn, i feel like a noob.... lolThat should be the least of your worries right now. github.com/jvanegmond
Ealric Posted February 27, 2009 Posted February 27, 2009 Don't knock yourself for trying to learn something. You may be reinventing the wheel, and badly even, but again it is "your" source and at least you'll understand it. I've taken very weak and small projects, built upon them, and sometimes they start off looking like a cracked egg but eventually turn into something more like an omelette. Keep working at it - we all do. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]
PsaltyDS Posted February 28, 2009 Posted February 28, 2009 Don't knock yourself for trying to learn something. You may be reinventing the wheel, and badly even, but again it is "your" source and at least you'll understand it. I've taken very weak and small projects, built upon them, and sometimes they start off looking like a cracked egg but eventually turn into something more like an omelette. Keep working at it - we all do.I made the comment earlier in this topic because I have been there personally. I had worked on a password keeper based on AutoIt with SQLite and my modified version of __StringEncrypt (based on SkinnyWhiteGuy's binary RC4 func). Trying to make myself think "paranoid enough" to anticipate vulnerabilities, the project became a little silly in its complexity. Then I had that "Doh!" moment, asking why I hadn't searched for existing tools a long time ago. There are some good ones out there, and PasswordSafe covered our needs.The attempt at my own app for this was educational, and so not entirely wasted. But in this case there is an open source app already out there, used and tested by thousands, under current maintenance and continued improvement, and developed by people who are recognized subject matter experts in encryption. My AutoIt-Fu is just never going to be THAT strong. 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now