Jump to content

random password file encryption


7h331337
 Share

Recommended Posts

this program takes the selected file and encrypts it using the password but the password is completely randomly generated it is just the same length as your password that you put in. it dumps the passwords to a file and dumps the encrypted text to a different file so without the password file you cant decrypt the text.

#Region 
#AutoIt3Wrapper_icon=..\..\..\Program Files\AutoIt3\Icons\au3.ico
#AutoIt3Wrapper_outfile=cryptofiles.exe
#AutoIt3Wrapper_Res_Comment=props to the peeps at hak5 and at autoit
#AutoIt3Wrapper_Res_Description=Random PASSWORD ENCRYPTION.
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=pmc (TODAY) created by 7h331337. your-account@hotmail.co.uk
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion 
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <string.au3>
#include <File.au3>
Global $npass, $percent1 , $percent
Dim $line
Dim $pass
$Form1 = GUICreate("Form1", 384, 320, 151, 169)
GUISetBkColor(0x00000)
$Edit1 = GUICtrlCreateEdit("", 16, 40, 177, 233)
GUICtrlSetBkColor(-1, 0x00000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetFont(-1,12)
$Edit2 = GUICtrlCreateEdit("", 200, 40, 177, 233)
GUICtrlSetBkColor(-1, 0x00000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetFont(-1,12)
$Input1 = GUICtrlCreateInput("", 100, 10, 307, 21)
GUICtrlSetBkColor(-1, 0x00000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetFont(-1,12)
$lable1 = GUICtrlCreateLabel("password", 16, 10, 80)
GUICtrlSetFont(-1,12)
GUICtrlSetColor(-1, 0xffffff)
$Button1 = GUICtrlCreateButton("encrypt", 16, 283, 177, 25, 0)
GUICtrlSetBkColor(-1, 0x00000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetFont(-1,12)
$Button2 = GUICtrlCreateButton("decrypt", 200, 283, 177, 25, 0)
GUICtrlSetBkColor(-1, 0x00000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetFont(-1,12)
GUISetState(@SW_SHOW)
msgbox(0,"How to use","type a password of any size and then click the encryped button select your file" & @crlf & "to decryped click the dycrypt button and select the files")
MAIN()
Func MAIN()
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                encrypt()
            Case $Button2
                decrypt()
        EndSwitch
        
    WEnd
EndFunc  ;==>MAIN

Func encrypt()
    $file = FileOpenDialog("file to encrypt",@scriptdir,"text file (*.txt)")
    $filename = StringSplit($file,"\")
    $filename = StringSplit($filename[$filename[0]],".")
    $file = FileRead($file)
    GUICtrlSetData($edit1,$file)

    MsgBox(0, "starting...", "this may take a moment")
    $string1 = StringSplit(GUICtrlRead($Edit1), @CRLF)
    
    ProgressOn("encrypting...","progress on the encryption")
    per($string1[0])
    For $i = 1 To $string1[0] Step 1
    
        $random = Random(1, 5, 1)
        If $string1[$i] > "" Then
            $percent = $percent + $percent1
            $string = _StringEncrypt(1, $string1[$i], GUICtrlRead($Input1), $random)
            FileWriteLine($filename[1] & ".enc", $string)
            FileWriteLine($filename[1] & ".pass", GUICtrlRead($Input1) & "" & $random)
            GUICtrlSetData($Edit2, $string & @CRLF)
            pass()
            ProgressSet($percent, $string1[$i])
        EndIf
    Next
    ProgressOff()
    FileClose($file)
    msgbox(0,"INFO!!!","done")
    main()
    if @error = true Then
        Exit
    EndIf
    
EndFunc  ;==>encrypt
Func pass()
    $npass = ""
    $pass = StringSplit(GUICtrlRead($Input1), "")
    For $i = 1 To $pass[0] Step 1
        $ran = Random(2, 255, 1)
        $passe = Asc($pass[$i]) + $ran
        If $passe > 255 Then
            $passe = $passe - 255
        EndIf
        $passe = Chr($passe)
        $npass = $npass & $passe
        GUICtrlSetData($Input1, $npass)
        Sleep(5)
    Next
    GUICtrlSetData($Input1, $npass)
EndFunc  ;==>pass
Func decrypt()
    GUICtrlSetData($Edit1, "")
    GUICtrlSetData($Edit2, "")
    $file = FileOpenDialog("select file", @ScriptDir, "enc file (*.enc)")

        $filename = StringSplit($file,"/")
    $filename = StringSplit($filename,".")
    $file2 = FileOpenDialog("select file", @ScriptDir, "password file (*.pass)")
    _FileReadToArray($file, $line)
    sleep(5)
    _FileReadToArray($file2, $pass)
    sleep(5)
    If @error = True Then
        MsgBox(0, "ERROR!!!", "YOU DID NOT SELECT A FILE")
    MAIN()
    EndIf
        ProgressOn("decrypting...","progress on the decryption")
            per($line[0])
    For $i = 1 To $line[0] Step 1
        
        If $line[$i] > "" Then
                    $percent = $percent + $percent1
            GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & @CRLF & $line[$i])
            $ran = StringSplit($pass[$i], "")
            $string = _StringEncrypt(0, $line[$i], $ran[1], $ran[2])
            FileWriteLine($filename[1] & ".txt", $string)
            GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & @CRLF & $string)
            ProgressSet($percent, $line[$i])

    
        EndIf
    Next
    ProgressOff()
    msgbox(0,"INFO!!!","done")
        main()
    if @error = true Then
        Exit
    EndIf
EndFunc  ;==>decrypt
func per($stringp)
$percent1 = 100 / $stringp
Return $percent1

EndFunc
Edited by 7h331337
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...