Sign in to follow this  
Followers 0
Aceguy

Encrypt to file

18 posts in this topic

#1 ·  Posted (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

#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 by Aceguy

Share this post


Link to post
Share on other sites



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?

Share this post


Link to post
Share on other sites

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?

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 z

E for a letter h

j for a letter q

ect.....

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

this is the code that i want but i have a problem...

#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 by Aceguy

Share this post


Link to post
Share on other sites

Use == instead.

if $ss[$count] == Chr($beta[$ct2]) then

Share this post


Link to post
Share on other sites

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 ..

Share this post


Link to post
Share on other sites

Works.... thanks all

#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)

Share this post


Link to post
Share on other sites

#12 ·  Posted (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 by Aceguy

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

:P


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

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]

Share this post


Link to post
Share on other sites

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.

:P


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

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  
Followers 0