Immensee Posted June 6, 2006 Share Posted June 6, 2006 Hey, i've just created a program that can encrypt a file and also decrypt a file but it only encrypts/decrypts files with strings (like .txt or .au3)... I want that the program also encrypts images (JPG/BMP etc.) Im using ofcourse _StringEncrypt.. but if you open a .JPG with notepad it also shows alot of strings. So it must be possible to _StringEncrypt an Image.. Cn someone help me please, I'll be very happy Bye -ImMenSe Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 6, 2006 Moderators Share Posted June 6, 2006 (edited) Someone did this in Java not to long ago, it was posted in the chat forum.It was Nova Edited June 6, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Paulie Posted June 6, 2006 Share Posted June 6, 2006 Hey, i've just created a program that can encrypt a file and also decrypt a file but it only encrypts/decrypts files with strings (like .txt or .au3)... I want that the program also encrypts images (JPG/BMP etc.)Im using ofcourse _StringEncrypt.. but if you open a .JPG with notepad it also shows alot of strings.So it must be possible to _StringEncrypt an Image.. Cn someone help me please,I'll be very happy Bye-ImMenSe never tried it, but if you saved the image as a notepad, then _stringencrypt that, then had it resave as a jpg then wouldn't that work? Link to comment Share on other sites More sharing options...
w0uter Posted June 6, 2006 Share Posted June 6, 2006 (edited) bmp's have non-renderable content (like NULL chars & bells) (the Nulls are the worst though since they ternminate the string) so you would have to do a binarystring conversion and encrypt that. Edited June 6, 2006 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Simucal Posted June 6, 2006 Share Posted June 6, 2006 RazerM's Encrypt0r can encrypt any file. Look for it in Scripts and Scraps. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 never tried it, but if you saved the image as a notepad, then _stringencrypt that, then had it resave as a jpg then wouldn't that work?Yes, i used _StringEncrypt with _StringReverse but if i test it on Images it'll show a blank notepad..But that's because like W0uter saidI'll try the things that the others saidthanks for help -ImMenSe Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 Hey, i've searched for 'binary encryption' but couldn't find anything about it, Can someone help me with that? thanks -ImMenSe Link to comment Share on other sites More sharing options...
Simucal Posted June 7, 2006 Share Posted June 7, 2006 Hey, i've searched for 'binary encryption' but couldn't find anything about it, Can someone help me with that?thanks-ImMenSeI've already told you what thread to look for in regards to encrypting images in AutoIt.Here is the exact link: http://www.autoitscript.com/forum/index.ph...47&hl=encrypt0r"Encrypt0r with Encrypted Image Viewer"Read the source, and adapt it to do what you want. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 I've already told you what thread to look for in regards to encrypting images in AutoIt.Here is the exact link: http://www.autoitscript.com/forum/index.ph...47&hl=encrypt0r"Encrypt0r with Encrypted Image Viewer"Read the source, and adapt it to do what you want.I couldn't find it but thanks -imMenSe Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 Ummm... He created an .EXE... and i don't have a decompiler.. Could someone give me a decompiler or is that forbidden? -ImMenSe Link to comment Share on other sites More sharing options...
Simucal Posted June 7, 2006 Share Posted June 7, 2006 (edited) AutoIt comes with a decompiler called Exe2Au3. I have done it for you: expandcollapse popup; <AUT2EXE VERSION: 3.1.1.0> ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-START: C:\Documents and Settings\FrazerMcLean\My Documents\AutoIt\Encrypt0r\GUI9.au3> ; ---------------------------------------------------------------------------- #NoTrayIcon ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-START: C:\Program Files\AutoIt3\Include\GUIConstants.au3> ; ---------------------------------------------------------------------------- ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.1.98 (beta) ; Language: English ; Description: Constants to be used in GUI applications. ; ; ------------------------------------------------------------------------------ ; Events and messages Global Const $GUI_EVENT_CLOSE = -3 Global Const $GUI_EVENT_MINIMIZE = -4 Global Const $GUI_EVENT_RESTORE = -5 Global Const $GUI_EVENT_MAXIMIZE = -6 Global Const $GUI_EVENT_PRIMARYDOWN = -7 Global Const $GUI_EVENT_PRIMARYUP = -8 Global Const $GUI_EVENT_SECONDARYDOWN = -9 Global Const $GUI_EVENT_SECONDARYUP = -10 Global Const $GUI_EVENT_MOUSEMOVE = -11 Global Const $GUI_EVENT_RESIZED = -12 Global Const $GUI_EVENT_DROPPED = -13 Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG' ; State Global Const $GUI_AVISTOP = 0 Global Const $GUI_AVISTART = 1 Global Const $GUI_AVICLOSE = 2 Global Const $GUI_CHECKED = 1 Global Const $GUI_INDETERMINATE = 2 Global Const $GUI_UNCHECKED = 4 Global Const $GUI_DROPACCEPTED = 8 Global Const $GUI_ACCEPTFILES = $GUI_DROPACCEPTED ; to be suppressed Global Const $GUI_SHOW = 16 Global Const $GUI_HIDE = 32 Global Const $GUI_ENABLE = 64 Global Const $GUI_DISABLE = 128 Global Const $GUI_FOCUS = 256 Global Const $GUI_DEFBUTTON = 512 Global Const $GUI_EXPAND = 1024 Global Const $GUI_ONTOP = 2048 ; Font Global Const $GUI_FONTITALIC = 2 Global Const $GUI_FONTUNDER = 4 Global Const $GUI_FONTSTRIKE = 8 ; Resizing Global Const $GUI_DOCKAUTO = 0x0001 Global Const $GUI_DOCKLEFT = 0x0002 Global Const $GUI_DOCKRIGHT = 0x0004 Global Const $GUI_DOCKHCENTER = 0x0008 Global Const $GUI_DOCKTOP = 0x0020 Global Const $GUI_DOCKBOTTOM = 0x0040 Global Const $GUI_DOCKVCENTER = 0x0080 Global Const $GUI_DOCKWIDTH = 0x0100 Global Const $GUI_DOCKHEIGHT = 0x0200 Global Const $GUI_DOCKSIZE = 0x0300 ; width+height Global Const $GUI_DOCKMENUBAR = 0x0220 ; top+height Global Const $GUI_DOCKSTATEBAR = 0x0240 ; bottom+height Global Const $GUI_DOCKALL = 0x0322 ; left+top+width+height Global Const $GUI_DOCKBORDERS = 0x0066 ; left+top+right+bottom ; Window Styles Global Const $WS_TILED = 0 Global Const $WS_OVERLAPPED = 0 Global Const $WS_MAXIMIZEBOX = 0x00010000 Global Const $WS_MINIMIZEBOX = 0x00020000 Global Const $WS_TABSTOP = 0x00010000 Global Const $WS_GROUP = 0x00020000 Global Const $WS_SIZEBOX = 0x00040000 Global Const $WS_THICKFRAME = 0x00040000 Global Const $WS_SYSMENU = 0x00080000 Global Const $WS_HSCROLL = 0x00100000 Global Const $WS_VSCROLL = 0x00200000 Global Const $WS_DLGFRAME = 0x00400000 Global Const $WS_BORDER = 0x00800000 Global Const $WS_CAPTION = 0x00C00000 Global Const $WS_OVERLAPPEDWINDOW = 0x00CF0000 Global Const $WS_TILEDWINDOW = 0x00CF0000 Global Const $WS_MAXIMIZE = 0x01000000 Global Const $WS_CLIPCHILDREN = 0x02000000 Global Const $WS_CLIPSIBLINGS = 0x04000000 Global Const $WS_DISABLED = 0x08000000 Global Const $WS_VISIBLE = 0x10000000 Global Const $WS_MINIMIZE = 0x20000000 Global Const $WS_CHILD = 0x40000000 Global Const $WS_POPUP = 0x80000000 Global Const $WS_POPUPWINDOW = 0x80880000 Global Const $DS_MODALFRAME = 0x80 Global Const $DS_SETFOREGROUND = 0x00000200 Global Const $DS_CONTEXTHELP = 0x00002000 ; Window Extended Styles Global Const $WS_EX_ACCEPTFILES = 0x00000010 Global Const $WS_EX_MDICHILD = 0x00000040 Global Const $WS_EX_APPWINDOW = 0x00040000 Global Const $WS_EX_CLIENTEDGE = 0x00000200 Global Const $WS_EX_CONTEXTHELP = 0x00000400 Global Const $WS_EX_DLGMODALFRAME = 0x00000001 Global Const $WS_EX_LEFTSCROLLBAR = 0x00004000 Global Const $WS_EX_OVERLAPPEDWINDOW = 0x00000300 Global Const $WS_EX_RIGHT = 0x00001000 Global Const $WS_EX_STATICEDGE = 0x00020000 Global Const $WS_EX_TOOLWINDOW = 0x00000080 Global Const $WS_EX_TOPMOST = 0x00000008 Global Const $WS_EX_TRANSPARENT = 0x00000020 Global Const $WS_EX_WINDOWEDGE = 0x00000100 Global Const $WS_EX_LAYERED = 0x00080000 Global Const $GUI_WS_EX_PARENTDRAG = 0x00100000 ; listView Extended Styles Global Const $LVS_EX_FULLROWSELECT = 0x00000020 Global Const $LVS_EX_GRIDLINES = 0x00000001 Global Const $LVS_EX_SUBITEMIMAGES = 0x00000002 Global Const $LVS_EX_CHECKBOXES = 0x00000004 Global Const $LVS_EX_TRACKSELECT = 0x00000008 Global Const $LVS_EX_HEADERDRAGDROP = 0x00000010 Global Const $LVS_EX_FLATSB = 0x00000100 Global Const $LVS_EX_BORDERSELECT = 0x00008000 ;Global Const $LVS_EX_MULTIWORKAREAS = 0x00002000 ;Global Const $LVS_EX_SNAPTOGRID = 0x00080000 ;Global Const $LVS_EX_DOUBLEBUFFER = 0x00010000 ; Tab Extended Styles Global Const $TCS_EX_FLATSEPARATORS = 0x1 ;Global Const $TCS_EX_REGISTERDROP = 0x2 ; Label/Pic/Icon Global Const $SS_LEFT = 0 Global Const $SS_CENTER = 1 Global Const $SS_RIGHT = 2 Global Const $SS_ICON = 3 Global Const $SS_BLACKRECT = 4 Global Const $SS_GRAYRECT = 5 Global Const $SS_WHITERECT = 6 Global Const $SS_BLACKFRAME = 7 Global Const $SS_GRAYFRAME = 8 Global Const $SS_WHITEFRAME = 9 Global Const $SS_SIMPLE = 11 Global Const $SS_LEFTNOWORDWRAP = 12 Global Const $SS_BITMAP = 15 Global Const $SS_ETCHEDHORZ = 16 Global Const $SS_ETCHEDVERT = 17 Global Const $SS_ETCHEDFRAME = 18 Global Const $SS_NOPREFIX = 0x0080 Global Const $SS_NOTIFY = 0x0100 Global Const $SS_CENTERIMAGE = 0x0200 Global Const $SS_RIGHTJUST = 0x0400 Global Const $SS_SUNKEN = 0x1000 ; Group Global Const $BS_GROUPBOX = 0x0007 ; Button Global Const $BS_BOTTOM = 0x0800 Global Const $BS_CENTER = 0x0300 Global Const $BS_DEFPUSHBUTTON = 0x0001 Global Const $BS_LEFT = 0x0100 Global Const $BS_MULTILINE = 0x2000 Global Const $BS_PUSHBOX = 0x000A Global Const $BS_PUSHLIKE = 0x1000 Global Const $BS_RIGHT = 0x0200 Global Const $BS_RIGHTBUTTON = 0x0020 Global Const $BS_TOP = 0x0400 Global Const $BS_VCENTER = 0x0C00 Global Const $BS_FLAT = 0x8000 Global Const $BS_ICON = 0x0040 Global Const $BS_BITMAP = 0x0080 ; Checkbox Global Const $BS_3STATE = 0x0005 Global Const $BS_AUTO3STATE = 0x0006 Global Const $BS_AUTOCHECKBOX = 0x0003 Global Const $BS_CHECKBOX = 0x0002 ; Radio Global Const $BS_AUTORADIOBUTTON = 0x0009 ; Combo Global Const $CBS_SIMPLE = 0x0001 Global Const $CBS_DROPDOWN = 0x0002 Global Const $CBS_DROPDOWNLIST = 0x0003 Global Const $CBS_AUTOHSCROLL = 0x0040 Global Const $CBS_OEMCONVERT = 0x0080 Global Const $CBS_SORT = 0x0100 Global Const $CBS_NOINTEGRALHEIGHT = 0x0400 Global Const $CBS_DISABLENOSCROLL = 0x0800 Global Const $CBS_UPPERCASE = 0x2000 Global Const $CBS_LOWERCASE = 0x4000 ; Listbox Global Const $LBS_NOTIFY = 0x0001 Global Const $LBS_SORT = 0x0002 Global Const $LBS_USETABSTOPS = 0x0080 Global Const $LBS_NOINTEGRALHEIGHT = 0x0100 Global Const $LBS_DISABLENOSCROLL = 0x1000 Global Const $LBS_NOSEL = 0x4000 Global Const $LBS_STANDARD = 0xA00003 ; Edit/Input Global Const $ES_LEFT = 0 Global Const $ES_CENTER = 1 Global Const $ES_RIGHT = 2 Global Const $ES_MULTILINE = 4 Global Const $ES_UPPERCASE = 8 Global Const $ES_LOWERCASE = 16 Global Const $ES_PASSWORD = 32 Global Const $ES_AUTOVSCROLL = 64 Global Const $ES_AUTOHSCROLL = 128 Global Const $ES_NOHIDESEL = 256 Global Const $ES_OEMCONVERT = 1024 Global Const $ES_READONLY = 2048 Global Const $ES_WANTRETURN = 4096 Global Const $ES_NUMBER = 8192 ;Global Const $ES_DISABLENOSCROLL = 8192 ;Global Const $ES_SUNKEN = 16384 ;Global Const $ES_VERTICAL = 4194304 ;Global Const $ES_SELECTIONBAR = 16777216 ; Date Global Const $DTS_SHORTDATEFORMAT = 0 Global Const $DTS_UPDOWN = 1 Global Const $DTS_SHOWNONE = 2 Global Const $DTS_LONGDATEFORMAT = 4 Global Const $DTS_TIMEFORMAT = 9 Global Const $DTS_RIGHTALIGN = 32 ; MonthCal Global Const $MCS_NOTODAY = 16 Global Const $MCS_NOTODAYCIRCLE = 8 Global Const $MCS_WEEKNUMBERS = 4 ; Progress bar Global Const $PBS_SMOOTH = 1 Global Const $PBS_VERTICAL = 4 ; AVI clip Global Const $ACS_CENTER = 1 Global Const $ACS_TRANSPARENT = 2 Global Const $ACS_AUTOPLAY = 4 Global Const $ACS_TIMER = 8 Global Const $ACS_NONTRANSPARENT = 16 ; Tab Global Const $TCS_SCROLLOPPOSITE = 0x0001 Global Const $TCS_BOTTOM = 0x0002 Global Const $TCS_RIGHT = 0x0002 Global Const $TCS_MULTISELECT = 0x0004 Global Const $TCS_FLATBUTTONS = 0x0008 Global Const $TCS_FORCEICONLEFT = 0x0010 Global Const $TCS_FORCELABELLEFT = 0x0020 Global Const $TCS_HOTTRACK = 0x0040 Global Const $TCS_VERTICAL = 0x0080 Global Const $TCS_TABS = 0x0000 Global Const $TCS_BUTTONS = 0x0100 Global Const $TCS_SINGLELINE = 0x0000 Global Const $TCS_MULTILINE = 0x0200 Global Const $TCS_RIGHTJUSTIFY = 0x0000 Global Const $TCS_FIXEDWIDTH = 0x0400 Global Const $TCS_RAGGEDRIGHT = 0x0800 Global Const $TCS_FOCUSONBUTTONDOWN = 0x1000 Global Const $TCS_OWNERDRAWFIXED = 0x2000 Global Const $TCS_TOOLTIPS = 0x4000 Global Const $TCS_FOCUSNEVER = 0x8000 ; TreeView Global Const $TVS_HASBUTTONS = 0x0001 Global Const $TVS_HASLINES = 0x0002 Global Const $TVS_LINESATROOT = 0x0004 ;Global Const $TVS_EDITLABELS = 0x0008 Global Const $TVS_DISABLEDRAGDROP = 0x0010 Global Const $TVS_SHOWSELALWAYS = 0x0020 ;Global Const $TVS_RTLREADING = 0x0040 Global Const $TVS_NOTOOLTIPS = 0x0080 Global Const $TVS_CHECKBOXES = 0x0100 Global Const $TVS_TRACKSELECT = 0x0200 Global Const $TVS_SINGLEEXPAND = 0x0400 ;Global Const $TVS_INFOTIP = 0x0800 Global Const $TVS_FULLROWSELECT = 0x1000 Global Const $TVS_NOSCROLL = 0x2000 Global Const $TVS_NONEVENHEIGHT = 0x4000 ; Slider Global Const $TBS_AUTOTICKS = 0x0001 Global Const $TBS_VERT = 0x0002 Global Const $TBS_HORZ = 0x0000 Global Const $TBS_TOP = 0x0004 Global Const $TBS_BOTTOM = 0x0000 Global Const $TBS_LEFT = 0x0004 Global Const $TBS_RIGHT = 0x0000 Global Const $TBS_BOTH = 0x0008 Global Const $TBS_NOTICKS = 0x0010 Global Const $TBS_NOTHUMB = 0x0080 ; ListView Global Const $LVS_ICON = 0x0000 Global Const $LVS_REPORT = 0x0001 Global Const $LVS_SMALLICON = 0x0002 Global Const $LVS_LIST = 0x0003 Global Const $LVS_EDITLABELS = 0x0200 Global Const $LVS_NOCOLUMNHEADER = 0x4000 Global Const $LVS_NOSORTHEADER = 0x8000 Global Const $LVS_SINGLESEL = 0x0004 Global Const $LVS_SHOWSELALWAYS = 0x0008 Global Const $LVS_SORTASCENDING = 0X0010 Global Const $LVS_SORTDESCENDING = 0x0020 ; Updown Global Const $UDS_WRAP = 0x0001 Global Const $UDS_ALIGNRIGHT = 0x0004 Global Const $UDS_ALIGNLEFT = 0x0008 Global Const $UDS_ARROWKEYS = 0x0020 Global Const $UDS_HORZ = 0x0040 Global Const $UDS_NOTHOUSANDS = 0x0080 ; Graphic Global Const $GUI_GR_CLOSE = 1 Global Const $GUI_GR_LINE = 2 Global Const $GUI_GR_BEZIER = 4 Global Const $GUI_GR_MOVE = 6 Global Const $GUI_GR_COLOR = 8 Global Const $GUI_GR_RECT = 10 Global Const $GUI_GR_ELLIPSE = 12 Global Const $GUI_GR_PIE = 14 Global Const $GUI_GR_DOT = 16 Global Const $GUI_GR_PIXEL = 18 Global Const $GUI_GR_HINT = 20 Global Const $GUI_GR_REFRESH = 22 Global Const $GUI_GR_PENSIZE = 24 Global Const $GUI_GR_NOBKCOLOR = -2 ; Control default styles Global Const $GUI_SS_DEFAULT_AVI = $ACS_TRANSPARENT Global Const $GUI_SS_DEFAULT_BUTTON = 0 Global Const $GUI_SS_DEFAULT_CHECKBOX = 0 Global Const $GUI_SS_DEFAULT_COMBO = BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL) Global Const $GUI_SS_DEFAULT_DATE = $DTS_LONGDATEFORMAT Global Const $GUI_SS_DEFAULT_EDIT = BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL) Global Const $GUI_SS_DEFAULT_GRAPHIC = 0 Global Const $GUI_SS_DEFAULT_GROUP = 0 Global Const $GUI_SS_DEFAULT_ICON = $SS_NOTIFY Global Const $GUI_SS_DEFAULT_INPUT = BitOR($ES_LEFT, $ES_AUTOHSCROLL) Global Const $GUI_SS_DEFAULT_LABEL = 0 Global Const $GUI_SS_DEFAULT_LIST = BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY) Global Const $GUI_SS_DEFAULT_LISTVIEW = BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL) Global Const $GUI_SS_DEFAULT_MONTHCAL = 0 Global Const $GUI_SS_DEFAULT_PIC = $SS_NOTIFY Global Const $GUI_SS_DEFAULT_PROGRESS = 0 Global Const $GUI_SS_DEFAULT_RADIO = 0 Global Const $GUI_SS_DEFAULT_SLIDER = $TBS_AUTOTICKS Global Const $GUI_SS_DEFAULT_TAB = 0 Global Const $GUI_SS_DEFAULT_TREEVIEW = BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) Global Const $GUI_SS_DEFAULT_UPDOWN = $UDS_ALIGNRIGHT Global Const $GUI_SS_DEFAULT_GUI = BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) ; Background color special flags Global Const $GUI_BKCOLOR_DEFAULT = -1 Global Const $GUI_BKCOLOR_TRANSPARENT = -2 ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-END: C:\Program Files\AutoIt3\Include\GUIConstants.au3> ; ---------------------------------------------------------------------------- ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-START: C:\Program Files\AutoIt3\Include\file.au3> ; ---------------------------------------------------------------------------- ; Include Version:1.54 (2/23/2006) ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.0 ; Language: English ; Description: Functions that assist with files and directories. ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; Description: Returns the number of lines in the specified file. ; Syntax: _FileCountLines( $sFilePath ) ; Parameter(s): $sFilePath - Path and filename of the file to be read ; Requirement(s): None ; Return Value(s): On Success - Returns number of lines in the file ; On Failure - Returns 0 and sets @error = 1 ; Author(s): Tylo <tylo@start.no> ; Note(s): It does not count a final @LF as a line. ; ;=============================================================================== Func _FileCountLines($sFilePath) Local $N = FileGetSize($sFilePath) - 1 If @error Or $N = -1 Then Return 0 Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1 EndFunc ;==>_FileCountLines ;=============================================================================== ; ; Description: Creates or zero's out the length of the file specified. ; Syntax: _FileCreate( $sFilePath ) ; Parameter(s): $sFilePath - Path and filename of the file to be created ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets: ; @error = 1: Error opening specified file ; @error = 2: File could not be written to ; Author(s): Brian Keene <brian_keene@yahoo.com> ; Note(s): None ; ;=============================================================================== Func _FileCreate($sFilePath) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $hOpenFile Local $hWriteFile $hOpenFile = FileOpen($sFilePath, 2) If $hOpenFile = -1 Then SetError(1) Return 0 EndIf $hWriteFile = FileWrite($hOpenFile, "") If $hWriteFile = -1 Then SetError(2) Return 0 EndIf FileClose($hOpenFile) Return 1 EndFunc ;==>_FileCreate ;=============================================================================== ; ; Description: lists all files and folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax: _FileListToArray($sPath, $sFilter = "*", $iFlag = 0) ; Parameter(s): $sPath = Path to generate filelist for ; $iFlag = determines weather to return file or folders or both ; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $iFlag=0(Default) Return both files and folders ; $iFlag=1 Return files Only ; $iFlag=2 Return Folders Only ; ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $sFilter ; @Error=3 Invalid $iFlag ; ; Author(s): SolidSnake <MetalGearX91@Hotmail.com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; ; Special Thanks to Helge and Layer for help with the $iFlag update ;=============================================================================== Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0) Local $hSearch, $sFile, $asFileList[1] If Not FileExists($sPath) Then SetError(1) Return "" EndIf If (StringInStr($sFilter, "\")) or (StringInStr($sFilter, "/")) or (StringInStr($sFilter, ":")) or (StringInStr($sFilter, ">")) or (StringInStr($sFilter, "<")) or (StringInStr($sFilter, "|")) or (StringStripWS($sFilter, 8) = "") Then SetError(2) Return 0 EndIf If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then SetError(3) Return "" EndIf $asFileList[0] = 0 $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then SetError(0) Return 0 EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If $iFlag = 1 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop EndIf If $iFlag = 2 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop EndIf ReDim $asFileList[UBound($asFileList) + 1] $asFileList[0] = $asFileList[0] + 1 $asFileList[UBound($asFileList) - 1] = $sFile WEnd FileClose($hSearch) SetError(0) If $asFileList[0] = 0 Then Return "" Return $asFileList EndFunc ;==>_FileListToArray ;=============================================================================== ; Function Name: _FilePrint() ; Description: Prints a plain text file. ; Syntax: _FilePrint ( $s_File [, $i_Show] ) ; ; Parameter(s): $s_File = The file to print. ; $i_Show = The state of the window. (default = @SW_HIDE) ; ; Requirement(s): External: = shell32.dll (it's already in system32). ; Internal: = None. ; ; Return Value(s): On Success: = Returns 1. ; On Failure: = Returns 0 and sets @error according to the global constants list. ; ; Author(s): erifash <erifash [at] gmail [dot] com> ; ; Note(s): Uses the ShellExecute function of shell32.dll. ; ; Example(s): ; _FilePrint("C:\file.txt") ;=============================================================================== Func _FilePrint($s_File, $i_Show = @SW_HIDE) Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "print", _ "string", $s_File, _ "string", "", _ "string", "", _ "int", $i_Show) If $a_Ret[0] > 32 And Not @error Then Return 1 Else SetError($a_Ret[0]) Return 0 EndIf EndFunc ;==>_FilePrint ;=============================================================================== ; ; Description: Reads the specified file into an array. ; Syntax: _FileReadToArray( $sFilePath, $aArray ) ; Parameter(s): $sFilePath - Path and filename of the file to be read ; $aArray - The array to store the contents of the file ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets @error = 1 ; Author(s): Jonathan Bennett <jon at hiddensoft com> ; Note(s): None ; ;=============================================================================== Func _FileReadToArray($sFilePath, ByRef $aArray) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $hFile $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then SetError(1) Return 0 EndIf $aArray = StringSplit( StringStripCR( FileRead($hFile, FileGetSize($sFilePath))), @LF) FileClose($hFile) Return 1 EndFunc ;==>_FileReadToArray ;=============================================================================== ; ; Description: Write array to File. ; Syntax: _FileWriteFromArray( $sFilePath, $aArray ) ; Parameter(s): $sFilePath - Path and filename of the file to be written ; $a_Array - The array to retrieve the contents ; $i_Base - Start reading at this Array entry. ; $I_Ubound - End reading at this Array entry. ; Default UBound($a_Array) - 1 ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets @error = 1 ; Author(s): Jos van der Zande ; Note(s): None ; ;=============================================================================== Func _FileWriteFromArray($sFilePath, $a_Array, $i_Base = 0, $i_UBound = 0) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $hFile ; Check if we have a valid array as input If Not IsArray($a_Array) Then SetError(2) Return 0 EndIf ; determine last entry Local $last = UBound($a_Array) - 1 If $i_UBound < 1 Or $i_UBound > $last Then $i_UBound = $last If $i_Base < 0 Or $i_Base > $last Then $i_Base = 0 ; Open output file $hFile = FileOpen($sFilePath, 2) If $hFile = -1 Then SetError(1) Return 0 EndIf ; FileWrite($hFile, $a_Array[$i_Base]) For $x = $i_Base + 1 To $i_UBound FileWrite($hFile, @CRLF & $a_Array[$x]) Next FileClose($hFile) Return 1 EndFunc ;==>_FileWriteFromArray ;=============================================================================== ; ; Description: Writes the specified text to a log file. ; Syntax: _FileWriteLog( $sLogPath, $sLogMsg ) ; Parameter(s): $sLogPath - Path and filename to the log file ; $sLogMsg - Message to be written to the log file ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets: ; @error = 1: Error opening specified file ; @error = 2: File could not be written to ; Author(s): Jeremy Landes <jlandes@landeserve.com> ; Note(s): If the text to be appended does NOT end in @CR or @LF then ; a DOS linefeed (@CRLF) will be automatically added. ; ;=============================================================================== Func _FileWriteLog($sLogPath, $sLogMsg) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $sDateNow Local $sTimeNow Local $sMsg Local $hOpenFile Local $hWriteFile $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg $hOpenFile = FileOpen($sLogPath, 1) If $hOpenFile = -1 Then SetError(1) Return 0 EndIf $hWriteFile = FileWriteLine($hOpenFile, $sMsg) If $hWriteFile = -1 Then SetError(2) Return 0 EndIf FileClose($hOpenFile) Return 1 EndFunc ;==>_FileWriteLog ;======================================== ;Function name: _FileWriteToLine ;Description: Write text to specified line in a file ;Parameters: ; $sFile - The file to write to ; $iLine - The line number to write to ; $sText - The text to write ; $fOverWrite - if set to 1 will overwrite the old line ; if set to 0 will not overwrite ;Requirement(s): None ;Return Value(s): On success - 1 ; On Failure - 0 And sets @ERROR ; @ERROR = 1 - File has less lines than $iLine ; @ERROR = 2 - File does not exist ; @ERROR = 3 - Error opening file ; @ERROR = 4 - $iLine is invalid ; @ERROR = 5 - $fOverWrite is invalid ; @ERROR = 6 - $sText is invalid ;Author(s): cdkid ;Note(s): ;========================================= Func _FileWriteToLine($sFile, $iLine, $sText, $fOverWrite = 0) If $iLine <= 0 Then SetError(4) Return 0 EndIf If Not IsString($sText) Then SetError(6) Return 0 EndIf If $fOverWrite <> 0 And $fOverWrite <> 1 Then SetError(5) Return 0 EndIf If Not FileExists($sFile) Then SetError(2) Return 0 EndIf Local $filtxt = FileRead($sFile, FileGetSize($sFile)) $filtxt = StringSplit($filtxt, @CRLF, 1) If UBound($filtxt, 1) < $iLine Then SetError(1) Return 0 EndIf Local $fil = FileOpen($sFile, 2) If $fil = -1 Then SetError(3) Return 0 EndIf For $i = 1 To UBound($filtxt) - 1 If $i = $iLine Then If $fOverWrite = 1 Then If $sText <> '' Then FileWrite($fil, $sText & @CRLF) Else FileWrite($fil, $sText) EndIf EndIf If $fOverWrite = 0 Then FileWrite($fil, $filtxt[$i] & @CRLF) EndIf ElseIf $i < UBound($filtxt, 1) - 1 Then FileWrite($fil, $filtxt[$i] & @CRLF) ElseIf $i = UBound($filtxt, 1) - 1 Then FileWrite($fil, $filtxt[$i]) EndIf Next FileClose($fil) Return 1 EndFunc ;==>_FileWriteToLine ; =================================================================== ; Author: Jason Boggs <vampirevalik AT hotmail DOT com ; updated 2006/01/07 ; ; _PathFull($szRelPath) ; ; Creates a path based on the relative path you provide. For example, if you specify: ; "C:\test\folder\..\file.txt", the output would be "C:\test\file.txt" because of the ..\. ; If no relative path is specified, the current working directory is returned. If no drive is specified, ; the new path is relative to the current working directory. Passing only a drive will return the ; current working directory for that drive. This function depends on _PathSplit and _PathMake. ; Parameters: ; $szRelPath - IN - The relative path ; Returns: ; The newly created absolute path is returned (Same as $szABSPath) ; =================================================================== Func _PathFull($szRelPath) Local $drive, $dir, $file, $ext, $wDrive, $NULL Local $i, $nPos; For Opt("MustDeclareVars", 1) ; Let's use _PathSplit to make this a hell of a lot easier to work with _PathSplit($szRelPath, $drive, $dir, $file, $ext) _PathSplit(@WorkingDir, $wDrive, $NULL, $NULL, $NULL) ; If no drive specified, then we use the working directory to set our path relative to If Not StringLen($drive) Then $drive = $wDrive If StringLen(@WorkingDir) = StringLen($drive) + 1 Then $dir = StringTrimLeft(@WorkingDir, StringLen($drive)) & $dir Else $dir = StringTrimLeft(@WorkingDir, StringLen($drive)) & "\" & $dir EndIf EndIf ; If the only thing specified was the drive, then return the working directory for that drive If Not StringLen($dir) And Not StringLen($file) And Not StringLen($ext) Then If $drive = $wDrive Then Return @WorkingDir Return _PathMake($drive, "\", "", "") EndIf ; Look for any .\ and ..\ While StringInStr($dir, ".\") Or StringInStr($dir, "./") $nPos = StringInStr($dir, ".\") If $nPos = 0 Then $nPos = StringInStr($dir, "./") If $nPos = 0 Then ExitLoop If StringMid($dir, $nPos - 1, 1) = "." Then; It's ..\ For $i = ($nPos - 3) To 0 Step - 1 If StringMid($dir, $i, 1) = "\" Or StringMid($dir, $i, 1) = "/" Then ExitLoop Next If $i > 0 Then $dir = StringLeft($dir, $i) & StringRight($dir, StringLen($dir) - ($nPos + 1)) Else $dir = StringRight($dir, StringLen($dir) - ($nPos + 1)) EndIf Else; It's .\ $dir = StringLeft($dir, $nPos - 1) & StringRight($dir, StringLen($dir) - $nPos - 1) EndIf If Not StringLen($dir) Then $dir = "\" WEnd Return _PathMake($drive, $dir, $file, $ext) EndFunc ;==>_PathFull ; =================================================================== ; Author: Jason Boggs <vampirevalik AT hotmail DOT com ; ; _PathMake($szDrive, $szDir, $szFName, $szExt) ; ; Creates a string containing the path from drive, directory, file name and file extension parts. Not all parts must be ; passed. The path will still be built with what is passed. This doesn't check the validity of the path ; created, it could contain characters which are invalid on your filesystem. ; Parameters: ; $szDrive - IN - Drive (Can be UNC). If it's a drive letter, a : is automatically appended ; $szDir - IN - Directory. A trailing slash is added if not found (No preceeding slash is added) ; $szFName - IN - The name of the file ; $szExt - IN - The file extension. A period is supplied if not found in the extension ; Returns: ; The string for the newly created path ; =================================================================== Func _PathMake($szDrive, $szDir, $szFName, $szExt) ; Format $szDrive, if it's not a UNC server name, then just get the drive letter and add a colon Local $szFullPath ; If StringLen($szDrive) Then If Not (StringLeft($szDrive, 2) = "\\") Then $szDrive = StringLeft($szDrive, 1) & ":" EndIf ; Format the directory by adding any necessary slashes If StringLen($szDir) Then If Not (StringRight($szDir, 1) = "\") And Not (StringRight($szDir, 1) = "/") Then $szDir = $szDir & "\" EndIf ; Nothing to be done for the filename ; Add the period to the extension if necessary If StringLen($szExt) Then If Not (StringLeft($szExt, 1) = ".") Then $szExt = "." & $szExt EndIf $szFullPath = $szDrive & $szDir & $szFName & $szExt Return $szFullPath EndFunc ;==>_PathMake ; =================================================================== ; Author: Jason Boggs <vampirevalik AT hotmail DOT com ; ; _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt) ; ; Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a ; part is missing. ; Parameters: ; $szPath - IN - The path to be split (Can contain a UNC server or drive letter) ; $szDrive - OUT - String to hold the drive ; $szDir - OUT - String to hold the directory ; $szFName - OUT - String to hold the file name ; $szExt - OUT - String to hold the file extension ; Returns: ; Array with 5 elements where 0 = original path, 1 = drive, 2 = directory, 3 = filename, 4 = extension ; =================================================================== Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt) ; Set local strings to null (We use local strings in case one of the arguments is the same variable) Local $drive = "" Local $dir = "" Local $fname = "" Local $ext = "" Local $i, $pos; For Opt("MustDeclareVars", 1) ; Create an array which will be filled and returned later Local $array[5] $array[0] = $szPath; $szPath can get destroyed, so it needs set now ; Get drive letter if present (Can be a UNC server) If StringMid($szPath, 2, 1) = ":" Then $drive = StringLeft($szPath, 2) $szPath = StringTrimLeft($szPath, 2) ElseIf StringLeft($szPath, 2) = "\\" Then $szPath = StringTrimLeft($szPath, 2) ; Trim the \\ $pos = StringInStr($szPath, "\") If $pos = 0 Then $pos = StringInStr($szPath, "/") If $pos = 0 Then $drive = "\\" & $szPath; Prepend the \\ we stripped earlier $szPath = ""; Set to null because the whole path was just the UNC server name Else $drive = "\\" & StringLeft($szPath, $pos - 1) ; Prepend the \\ we stripped earlier $szPath = StringTrimLeft($szPath, $pos - 1) EndIf EndIf ; Set the directory and file name if present For $i = StringLen($szPath) To 0 Step - 1 If StringMid($szPath, $i, 1) = "\" Or StringMid($szPath, $i, 1) = "/" Then $dir = StringLeft($szPath, $i) $fname = StringRight($szPath, StringLen($szPath) - $i) ExitLoop EndIf Next ; If $szDir wasn't set, then the whole path must just be a file, so set the filename If StringLen($dir) = 0 Then $fname = $szPath ; Check the filename for an extension and set it For $i = StringLen($fname) To 0 Step - 1 If StringMid($fname, $i, 1) = "." Then $ext = StringRight($fname, StringLen($fname) - ($i - 1)) $fname = StringLeft($fname, $i - 1) ExitLoop EndIf Next ; Set the strings and array to what we found $szDrive = $drive $szDir = $dir $szFName = $fname $szExt = $ext $array[1] = $drive $array[2] = $dir $array[3] = $fname $array[4] = $ext Return $array EndFunc ;==>_PathSplit ; =================================================================== ; Author: Kurt (aka /dev/null) and JdeB ; ; _ReplaceStringInFile($szFileName, $szSearchString, $szReplaceString,$bCaseness = 0, $bOccurance = 0) ; ; Replaces a string ($szSearchString) with another string ($szReplaceString) the given TEXT file ; (via filename) ; ; Operation: ; The funnction opens the original file for reading and a temp file for writing. Then ; it reads in all lines and searches for the string. If it was found, the original line will be ; modified and written to the temp file. If the string was not found, the original line will be ; written to the temp file. At the end the original file will be deleted and the temp file will ; be renamed. ; ; Parameters: ; $szFileName name of the file to open. ; ATTENTION !! Needs the FULL path, not just the name returned by eg. FileFindNextFile ; $szSearchString The string we want to replace in the file ; $szReplaceString The string we want as a replacement for $szSearchString ; $fCaseness shall case matter? ; 0 = NO, case doe not matter (default), 1 = YES, case does matter ; $fOccurance shall we replace the string in every line or just the first occurance ; 0 = first only, 1 = ALL strings (default) ; ; Return Value(s): ; On Success Returns the number of occurences of $szSearchString we found ; ; On Failure Returns -1 sets @error ; @error=1 Cannot open file ; @error=2 Cannot open temp file ; @error=3 Cannot write to temp file ; @error=4 Cannot delete original file ; @error=5 Cannot rename/move temp file ; ; =================================================================== Func _ReplaceStringInFile($szFileName, $szSearchString, $szReplaceString, $fCaseness = 0, $fOccurance = 1) Local $iRetVal = 0 Local $szTempFile, $hWriteHandle, $aFileLines, $nCount, $sEndsWith, $hFile ;=============================================================================== ;== Read the file into an array ;=============================================================================== $hFile = FileOpen($szFileName, 0) If $hFile = -1 Then SetError(1) Return -1 EndIf Local $s_TotFile = FileRead($hFile, FileGetSize($szFileName)) If StringRight($s_TotFile, 2) = @CRLF Then $sEndsWith = @CRLF ElseIf StringRight($s_TotFile, 1) = @CR Then $sEndsWith = @CR ElseIf StringRight($s_TotFile, 1) = @LF Then $sEndsWith = @LF Else $sEndsWith = "" EndIf $aFileLines = StringSplit(StringStripCR($s_TotFile), @LF) FileClose($hFile) ;=============================================================================== ;== Open the temporary file in write mode ;=============================================================================== $szTempFile = _TempFile() $hWriteHandle = FileOpen($szTempFile, 2) If $hWriteHandle = -1 Then SetError(2) Return -1 EndIf ;=============================================================================== ;== Loop through the array and search for $szSearchString ;=============================================================================== For $nCount = 1 To $aFileLines[0] If StringInStr($aFileLines[$nCount], $szSearchString, $fCaseness) Then $aFileLines[$nCount] = StringReplace($aFileLines[$nCount], $szSearchString, $szReplaceString, 1 - $fOccurance, $fCaseness) $iRetVal = $iRetVal + 1 ;====================================================================== ;== If we want just the first string replaced, copy the rest of the lines ;== and stop ;====================================================================== If $fOccurance = 0 Then $iRetVal = 1 ExitLoop EndIf EndIf Next ;=============================================================================== ;== Write the lines to a temp file. ;=============================================================================== For $nCount = 1 To $aFileLines[0] - 1 If FileWriteLine($hWriteHandle, $aFileLines[$nCount]) = 0 Then SetError(3) FileClose($hWriteHandle) Return -1 EndIf Next ; Write the last record and ensure it ends wit hthe same as the input file If $aFileLines[$nCount] <> "" Then FileWrite($hWriteHandle, $aFileLines[$nCount] & $sEndsWith) FileClose($hWriteHandle) ;====================================================================== ;== Delete the original file ;====================================================================== If FileDelete($szFileName) = 0 Then SetError(4) Return -1 EndIf ;====================================================================== ;== Rename the temp file to the original file ;====================================================================== If FileMove($szTempFile, $szFileName) = 0 Then SetError(5) Return -1 EndIf Return $iRetVal EndFunc ;==>_ReplaceStringInFile ;======================================================================================================== ; ; Function Name: _TempFile([s_DirectoryName],[s_FilePrefix], [s_FileExtension], [i_RandomLength) ; Description: Generate a name for a temporary file. The file is guaranteed not to already exist. ; Parameter(s): ; $s_DirectoryName optional Name of directory for filename, defaults to @TempDir ; $s_FilePrefix optional File prefixname, defaults to "~" ; $s_FileExtension optional File extenstion, defaults to ".tmp" ; $i_RandomLength optional Number of characters to use to generate a unique name, defaults to 7 ; Requirement(s): None. ; Return Value(s): Filename of a temporary file which does not exist. ; Author(s): Dale (Klaatu) Thompson ; Hans Harder - Added Optional parameters ; Notes: None. ; ;======================================================================================================== Func _TempFile($s_DirectoryName = @TempDir, $s_FilePrefix = "~", $s_FileExtension = ".tmp", $i_RandomLength = 7) Local $s_TempName ; Check parameters If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @TempDir ; First reset to default temp dir If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @ScriptDir ; Still wrong then set to Scriptdir ; add trailing \ for directory name If StringRight($s_DirectoryName, 1) <> "\" Then $s_DirectoryName = $s_DirectoryName & "\" ; Do $s_TempName = "" While StringLen($s_TempName) < $i_RandomLength $s_TempName = $s_TempName & Chr(Random(97, 122, 1)) WEnd $s_TempName = $s_DirectoryName & $s_FilePrefix & $s_TempName & $s_FileExtension Until Not FileExists($s_TempName) Return ($s_TempName) EndFunc ;==>_TempFile ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-END: C:\Program Files\AutoIt3\Include\file.au3> ; ---------------------------------------------------------------------------- ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-START: C:\Program Files\AutoIt3\Include\string.au3> ; ---------------------------------------------------------------------------- ; Include Version:1.49 (1/17/2006) ;=============================================================================== ; ; Function Name: _HexToStr("hex") ; Description: Convert a hex string of characters to ASCII Characters. ; Parameter(s): $strHex is the hex string you want to convert. ; Requirement(s): Hex Input. ; Return Value(s): On Success - Returns the converted string of characters. ; On Failure - -1 and sets @ERROR = 1 ; Author(s): Jarvis Stubblefield ; Corrected: 2005/09/04 jpm error checking ; ;=============================================================================== Func _HexToString($strHex) Local $strChar, $aryHex, $i, $iDec, $Char, $iOne, $iTwo $aryHex = StringSplit($strHex, "") If Mod($aryHex[0], 2) <> 0 Then SetError(1) Return -1 EndIf For $i = 1 To $aryHex[0] $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $iDec = Dec($iOne & $iTwo) If @error <> 0 Then SetError(1) Return -1 EndIf $Char = Chr($iDec) $strChar = $strChar & $Char Next Return $strChar EndFunc ;==>_HexToString ;=============================================================================== ; ; Function Name: _StringEncrypt() ; Description: RC4 Based string encryption ; Parameter(s): $i_Encrypt - 1 to encrypt, 0 to decrypt ; $s_EncryptText - string to encrypt ; $s_EncryptPassword - string to use as an encryption password ; $i_EncryptLevel - integer to use as number of times to encrypt string ; Requirement(s): None ; Return Value(s): On Success - Returns the string encrypted (blank) times with (blank) password ; On Failure - Returns a blank string and sets @error = 1 ; Author(s): Wes Wolfe-Wolvereness <Weswolf@aol.com> ; ;=============================================================================== ; Func _StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1) If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then SetError(1) Return '' ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then SetError(1) Return '' Else If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $i_EncryptLevel = 1 Local $v_EncryptModified Local $i_EncryptCountH Local $i_EncryptCountG Local $v_EncryptSwap Local $av_EncryptBox[256][2] Local $i_EncryptCountA Local $i_EncryptCountB Local $i_EncryptCountC Local $i_EncryptCountD Local $i_EncryptCountE Local $v_EncryptCipher Local $v_EncryptCipherBy If $i_Encrypt = 1 Then For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1 $i_EncryptCountG = '' $i_EncryptCountH = '' $v_EncryptModified = '' For $i_EncryptCountG = 1 To StringLen($s_EncryptText) If $i_EncryptCountH = StringLen($s_EncryptPassword) Then $i_EncryptCountH = 1 Else $i_EncryptCountH = $i_EncryptCountH + 1 EndIf $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) Next $s_EncryptText = $v_EncryptModified $i_EncryptCountA = '' $i_EncryptCountB = 0 $i_EncryptCountC = '' $i_EncryptCountD = '' $i_EncryptCountE = '' $v_EncryptCipherBy = '' $v_EncryptCipher = '' $v_EncryptSwap = '' $av_EncryptBox = '' Local $av_EncryptBox[256][2] For $i_EncryptCountA = 0 To 255 $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1)) $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA Next For $i_EncryptCountA = 0 To 255 $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256) $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0] $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0] $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap Next For $i_EncryptCountA = 1 To StringLen($s_EncryptText) $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256) $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256) $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256) ][0] $v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE) $v_EncryptCipher = $v_EncryptCipher & Hex($v_EncryptCipherBy, 2) Next $s_EncryptText = $v_EncryptCipher Next Else For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1 $i_EncryptCountB = 0 $i_EncryptCountC = '' $i_EncryptCountD = '' $i_EncryptCountE = '' $v_EncryptCipherBy = '' $v_EncryptCipher = '' $v_EncryptSwap = '' $av_EncryptBox = '' Local $av_EncryptBox[256][2] For $i_EncryptCountA = 0 To 255 $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1)) $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA Next For $i_EncryptCountA = 0 To 255 $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256) $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0] $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0] $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap Next For $i_EncryptCountA = 1 To StringLen($s_EncryptText) Step 2 $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256) $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256) $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256) ][0] $v_EncryptCipherBy = BitXOR(Dec(StringMid($s_EncryptText, $i_EncryptCountA, 2)), $i_EncryptCountE) $v_EncryptCipher = $v_EncryptCipher & Chr($v_EncryptCipherBy) Next $s_EncryptText = $v_EncryptCipher $i_EncryptCountG = '' $i_EncryptCountH = '' $v_EncryptModified = '' For $i_EncryptCountG = 1 To StringLen($s_EncryptText) If $i_EncryptCountH = StringLen($s_EncryptPassword) Then $i_EncryptCountH = 1 Else $i_EncryptCountH = $i_EncryptCountH + 1 EndIf $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) Next $s_EncryptText = $v_EncryptModified Next EndIf Return $s_EncryptText EndIf EndFunc ;==>_StringEncrypt ;=============================================================================== ; ; Function Name: _StringInsert(), version 1.02 ; Description: Inserts a string within another ; Parameters: $s_String - Original string ; $s_InsertString - String to insert ; $i_Position - Position to insert string (negatives values ; count from right hand side) ; Requirement(s): None ; Author(s): Louis Horvath <celeri@videotron.ca> ; ; Return value: upon success, returns a string containing the desired insert string. ; upon error, sets @error to the following values: ; @error = 1 : Source string empty / not a string ; @error = 2 : Insert string empty / not a string ; @error = 3 : Invalid position ; ; and returns original string unmodified. ;=============================================================================== Func _StringInsert($s_String, $s_InsertString, $i_Position) Local $i_Length, $s_Start, $s_End If $s_String = "" Or (Not IsString($s_String)) Then SetError(1) ; Source string empty / not a string Return $s_String ElseIf $s_InsertString = "" Or (Not IsString($s_String)) Then SetError(2) ; Insert string empty / not a string Return $s_String Else $i_Length = StringLen($s_String) ; Take a note of the length of the source string If (Abs($i_Position) > $i_Length) Or (Not IsInt($i_Position)) Then SetError(3) ; Invalid position Return $s_String EndIf EndIf ; If $i_Position at start of string If $i_Position = 0 Then Return $s_InsertString & $s_String ; Just add them up :) Easy :) ; If $i_Position is positive ElseIf $i_Position > 0 Then $s_Start = StringLeft($s_String, $i_Position) ; Chop off first part $s_End = StringRight($s_String, $i_Length - $i_Position) ; and the second part Return $s_Start & $s_InsertString & $s_End ; Assemble all three pieces together ; If $i_Position is negative ElseIf $i_Position < 0 Then $s_Start = StringLeft($s_String, Abs($i_Length + $i_Position)) ; Chop off first part $s_End = StringRight($s_String, Abs($i_Position)) ; and the second part Return $s_Start & $s_InsertString & $s_End ; Assemble all three pieces together EndIf EndFunc ;==>_StringInsert ;=============================================================================== ; ; Description: Changes a string to proper case, same a =Proper function in Excel ; Syntax: _StringProper( $sString) ; Parameter(s): $sString - String to change to proper case. ; Requirement(s): None ; Return Value(s): On Success - Returns the proper string. ; On Failure - Returns an empty string and sets @error = 1 ; Author(s): Jos van der Zande ; Note(s): None ; ;=============================================================================== Func _StringProper($s_Str) Local $iX = 0 Local $CapNext = 1 Local $s_nStr = "" Local $s_CurChar For $iX = 1 To StringLen($s_Str) $s_CurChar = StringMid($s_Str, $iX, 1) Select Case $CapNext = 1 If __CharacterIsApha($s_CurChar) Then $s_CurChar = StringUpper($s_CurChar) $CapNext = 0 EndIf Case Not __CharacterIsApha($s_CurChar) $CapNext = 1 Case Else $s_CurChar = StringLower($s_CurChar) EndSelect $s_nStr = $s_nStr & $s_CurChar Next Return ($s_nStr) EndFunc ;==>_StringProper ;=============================================================================== ; ; Description: Repeats a string a specified number of times. ; Syntax: _StringRepeat( $sString, $iRepeatCount ) ; Parameter(s): $sString - String to repeat ; $iRepeatCount - Number of times to repeat the string ; Requirement(s): None ; Return Value(s): On Success - Returns string with specified number of repeats ; On Failure - Returns an empty string and sets @error = 1 ; Author(s): Jeremy Landes <jlandes@landeserve.com> ; Note(s): None ; ;=============================================================================== Func _StringRepeat($sString, $iRepeatCount) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $sResult Select Case Not StringIsInt($iRepeatCount) SetError(1) Return "" Case StringLen($sString) < 1 SetError(1) Return "" Case $iRepeatCount <= 0 SetError(1) Return "" Case Else For $iCount = 1 To $iRepeatCount $sResult = $sResult & $sString Next Return $sResult EndSelect EndFunc ;==>_StringRepeat ;=============================================================================== ; ; Description: Reverses the contents of the specified string. ; Syntax: _StringReverse( $sString ) ; Parameter(s): $sString - String to reverse ; Requirement(s): None ; Return Value(s): On Success - Returns reversed string ; On Failure - Returns an empty string and sets @error = 1 ; Author(s): Jonathan Bennett <jon at hiddensoft com> ; Note(s): None ; ;=============================================================================== Func _StringReverse($sString) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $sReverse Local $iCount If StringLen($sString) >= 1 Then For $iCount = 1 To StringLen($sString) $sReverse = StringMid($sString, $iCount, 1) & $sReverse Next Return $sReverse Else SetError(1) Return "" EndIf EndFunc ;==>_StringReverse ;=============================================================================== ; ; Function Name: _StringToHex("string") ; Description: Convert a string of characters to hexadecimal. ; Parameter(s): $strChar is the string you want to convert. ; Requirement(s): String Input. ; Return Value(s): Returns the converted string in hexadecimal. ; Author(s): Jarvis Stubblefield ; Corrected: 2005/09/04 jpm error checking ; ;=============================================================================== Func _StringToHex($strChar) Local $aryChar, $i, $iDec, $hChar, $strHex $aryChar = StringSplit($strChar, "") For $i = 1 To $aryChar[0] $iDec = Asc($aryChar[$i]) $hChar = Hex($iDec, 2) $strHex = $strHex & $hChar Next Return $strHex EndFunc ;==>_StringToHex ;================================================================================= ; Helper functions Func __CharacterIsApha($s_Str) Local $a_Alpha = "abcdefghijklmnopqrstuvwxyz" Return (StringInStr($a_Alpha, $s_Str)) EndFunc ;==>__CharacterIsApha ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-END: C:\Program Files\AutoIt3\Include\string.au3> ; ---------------------------------------------------------------------------- ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-START: C:\Documents and Settings\FrazerMcLean\My Documents\AutoIt\Encrypt0r\image.au3> ; ---------------------------------------------------------------------------- ;=============================================================================== ; ; Description: Return JPEG, TIFF, BMP, PNG and GIF image size. ; Parameter(s): File name ; Requirement(s): None special ; Return Value(s): On Success - array with width and height ; On Failure empty string and sets @ERROR: ; 1 - Not valid image or info not found ; Author(s): YDY (Lazycat) ; Version: 1.1.00 ; Date: 15.03.2005 ; ;=============================================================================== Func _ImageGetSize($sFile) Local $sHeader = _FileReadAtOffsetHEX($sFile, 1, 24); Get header bytes Local $asIdent = StringSplit("FFD8 424D 89504E470D0A1A 4749463839 4749463837 4949 4D4D", " ") Local $anSize = "" For $i = 1 To $asIdent[0] If StringInStr($sHeader, $asIdent[$i]) = 1 Then Select Case $i = 1; JPEG $anSize = _ImageGetSizeJPG($sFile) Exitloop Case $i = 2; BMP $anSize = _ImageGetSizeSimple($sHeader, 19, 23, 0) Exitloop Case $i = 3; PNG $anSize = _ImageGetSizeSimple($sHeader, 19, 23, 1) Exitloop Case ($i = 4) or ($i = 5); GIF $anSize = _ImageGetSizeSimple($sHeader, 7, 9, 0) Exitloop Case $i = 6; TIFF MM $anSize = _ImageGetSizeTIF($sFile, 0) Exitloop Case $i = 7; TIFF II $anSize = _ImageGetSizeTIF($sFile, 1) Exitloop EndSelect Endif Next If not IsArray ($anSize) Then SetError(1) Return($anSize) EndFunc ;=============================================================================== ; ; Description: Get image size at given bytes ; Parameter(s): File header ; Return Value(s): Array with dimension ; ;=============================================================================== Func _ImageGetSizeSimple($sHeader, $nXoff, $nYoff, $nByteOrder) Local $anSize[2] $anSize[0] = _Dec(StringMid($sHeader, $nXoff*2-1, 4), $nByteOrder) $anSize[1] = _Dec(StringMid($sHeader, $nYoff*2-1, 4), $nByteOrder) Return ($anSize) EndFunc ;=============================================================================== ; ; Description: Get JPG image size (may be used standalone with checking) ; Parameter(s): File name ; Return Value(s): On Success - array with dimension ; ;=============================================================================== Func _ImageGetSizeJPG($sFile) Local $anSize[2], $sData, $sSeg, $nFileSize, $nPos = 3 $nFileSize = FileGetSize($sFile) While $nPos < $nFileSize $sData = _FileReadAtOffsetHEX ($sFile, $nPos, 4) If StringLeft($sData, 2) = "FF" then; Valid segment start If StringInStr("C0 C2 CA C1 C3 C5 C6 C7 C9 CB CD CE CF", StringMid($sData, 3, 2)) Then; Segment with size data $sSeg = _FileReadAtOffsetHEX ($sFile, $nPos + 5, 4) $anSize[1] = Dec(StringLeft($sSeg, 4)) $anSize[0] = Dec(StringRight($sSeg, 4)) Return($anSize) Else $nPos= $nPos + Dec(StringRight($sData, 4)) + 2 Endif Else ExitLoop Endif Wend Return("") EndFunc ;=============================================================================== ; ; Description: Get TIFF image size (may be used standalone with checking) ; Parameter(s): File name ; Return Value(s): On Success - array with dimension ; ;=============================================================================== Func _ImageGetSizeTIF($sFile, $nByteOrder) Local $anSize[2], $pos = 3 $nTagsOffset = _Dec(_FileReadAtOffsetHEX($sFile, 5, 4), $nByteOrder) + 1 $nFieldCount = _Dec(_FileReadAtOffsetHEX($sFile, $nTagsOffset, 2), $nByteOrder) For $i = 0 To $nFieldCount - 1 $sField = _FileReadAtOffsetHEX($sFile, $nTagsOffset + 2 + 12 * $i, 12) $sTag = StringLeft($sField, 4) If $nByteOrder Then $sTag = StringRight($sTag, 2) & StringLeft($sTag, 2) Select Case $sTag = "0001" $anSize[0] = _Dec(StringRight($sField, 8), $nByteOrder) Case $sTag = "0101" $anSize[1] = _Dec(StringRight($sField, 8), $nByteOrder) EndSelect Next If ($anSize[0] = 0) or ($anSize[1] = 0) Then Return("") Return($anSize) Endfunc ;=============================================================================== ; ; Description: Basic function that read binary data into HEX-string ; Parameter(s): File name, Start offset, Number bytes to read ; Return Value(s): Hex string ; ;=============================================================================== Func _FileReadAtOffsetHEX ($sFile, $nOffset, $nBytes) Local $hFile = FileOpen($sFile, 0) Local $sTempStr = "" FileRead($hFile, $nOffset - 1) For $i = $nOffset To $nOffset + $nBytes - 1 $sTempStr = $sTempStr & Hex(Asc(FileRead($hFile, 1)), 2) Next FileClose($hFile) Return ($sTempStr) Endfunc ;=============================================================================== ; ; Description: Basic function, similar Dec, but take in account byte order ; Parameter(s): Hex string, Byte order ; Return Value(s): Decimal value ; ;=============================================================================== Func _Dec($sHexStr, $nByteOrder) If $nByteOrder Then Return(Dec($sHexStr)) Local $sTempStr = "" While StringLen($sHexStr) > 0 $sTempStr = $sTempStr & StringRight($sHexStr, 2) $sHexStr = StringTrimRight($sHexStr, 2) WEnd Return (Dec($sTempStr)) EndFunc ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-END: C:\Documents and Settings\FrazerMcLean\My Documents\AutoIt\Encrypt0r\image.au3> ; ---------------------------------------------------------------------------- ;~ #include <Array.au3> #region ;gui FileInstall("C:\Documents and Settings\FrazerMcLean\My Documents\AutoIt\Encrypt0r\Encrypt0r.jpg", @ScriptDir & "\Encrypt0r.jpg", 1) FileInstall("C:\Documents and Settings\FrazerMcLean\My Documents\AutoIt\Encrypt0r\Encrypt0r2.jpg", @ScriptDir & "\Encrypt0r2.jpg", 1) FileInstall("C:\Documents and Settings\FrazerMcLean\My Documents\AutoIt\Encrypt0r\encrypt.com", "C:\Windows\encrypt.com", 1) SplashImageOn("Encrypt0r", @ScriptDir & "\Encrypt0r.jpg", 480, 160, -1, -1, 1) $time = IniRead((@scriptdir & "\config.ini"), "Settings", "Splash Time", "5000") If $time > 5000 Then $time=5000 If $time < 2000 Then $time=2000 Sleep($time) $GUI=GUICreate("Encrypt0r", 600, 500) ;GUI AutoItSetOption("GUICoordMode", 1) ;text tab $tab=GUICtrlCreateTab(10, 2, 583, 470) $tab0=GUICtrlCreateTabItem("Text Encryption") $tab0EditText = GuiCtrlCreateEdit('',20,33,560,342, $ES_MULTILINE) ; Creates main edit $tab0InputPass = GuiCtrlCreateInput('',20,380,100,20, 0x21) ; Creates the password box with hidden/centered input $tab0InputLevel = GuiCtrlCreateInput(1, 130, 380, 50, 20, 0x2001) $tab0UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($tab0inputlevel),10, 1) ; These two make the level input with the Up|Down ability $tab0EncryptButton = GuiCtrlCreateButton('Encrypt Text', 190, 380, 80, 25) ; Encryption button $tab0DecryptButton = GuiCtrlCreateButton('Decrypt Text', 275, 380, 80, 25) $tab0Copy = GuiCtrlCreateButton('Copy Text', 360, 380, 80, 25) $tab0Cut = GuiCtrlCreateButton('Cut Text', 360, 410, 80, 25) $tab0Paste = GuiCtrlCreateButton('Paste Text', 445, 380, 80, 25) $tab0clear = GuiCtrlCreateButton('Clear Text', 190, 410, 80, 25) $level = IniRead((@scriptdir & "\config.ini"), "Settings", "Encryption Level", 1) If $level > 10 Then $level = 10 If $level < 1 Then $level = 1 GUICtrlSetData($tab0InputLevel, $level) ; Decryption button GUICtrlCreateLabel('Key', 20, 405) GuiCtrlCreateLabel('Level',130,405) ; Simple text labels so you know what is what ;file tab $tab1=GUICtrlCreateTabItem("File Encryption") $tab1encrypt = GUICtrlCreateButton("Encrypt File", 20, 80, 80, 25) $tab1decrypt=GUICtrlCreateButton("Decrypt File", 110, 80, 80, 25) $tab1list = GUICtrlCreateListView("File|Extension|Full Filename",20, 130, 560, 330) $tab1log = GUICtrlCreateLabel("File Log:", 20, 115) $tab2=GUICtrlCreateTabItem("Encrypted Image Viewer") $tab2openimg = GUICtrlCreateButton("Open Encrypted Image", 20, 40, 120, 25) GUICtrlCreateTabitem ("") Dim $i = 0 Do $i = $i + 1 $file = IniRead((@scriptdir & "\Files.log"), "Encrypted Files", $i, "END") If $file = "END" Then ExitLoop EndIf $exist = FileExists(($file & ".encrypt")) If $exist = 1 Then Dim $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit($file, $szDrive, $szDir, $szFName, $szExt) GUICtrlCreateListViewItem(($szFName & "|" & $szExt & "|" & $file & ".encrypt"), $tab1list) EndIf Until $i = 1000000 Global Const $LVM_SETCOLUMNWIDTH = 0x101E GUICtrlSendMsg($tab1list, $LVM_SETCOLUMNWIDTH, 0, 115) GUICtrlSendMsg($tab1list, $LVM_SETCOLUMNWIDTH, 1, 65) GUICtrlSendMsg($tab1list, $LVM_SETCOLUMNWIDTH, 2, 375) ;menu $filemenu = GUICtrlCreateMenu ("&File") ;~ GUICtrlSetState(-1,$GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu ("&Help") $settingsitem = GUICtrlCreateMenuitem ("&Settings",$filemenu) ;~ GUICtrlSetState(-1,$GUI_DISABLE) $infoitem = GUICtrlCreateMenuitem ("&About..",$helpmenu) $infoitemn = GUICtrlCreateMenuitem ("&Info..", $helpmenu) $exititem = GUICtrlCreateMenuitem ("&Exit",$filemenu) $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1) $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line SplashOff() GUISetState(@SW_SHOW) #endregion ;start checks #region ;check encrypt.com If FileExists("C:\Windows\encrypt.com") Then $dir = IniRead((@scriptdir & "\config.ini"), "Settings", "Default Directory", "ERROR") If $dir = "ERROR" Or $dir = "" Then $defdir = FileSelectFolder("Choose the root folder when encrypting/decrypting files", "", 1 + 2 + 4) IniWrite((@scriptdir & "\config.ini"), "Settings", "Default Directory", $defdir) EndIf Else MsgBox(48,"File error!", "The Encryption File is Missing!! (encrypt.com)") Exit EndIf #endregion $number = IniRead(@ScriptDir & "\config.ini", "Recent Files", "Number", 0) $5th = IniRead(@ScriptDir & "\config.ini", "Recent Files", ($number-4), "ERR") $4th = IniRead(@ScriptDir & "\config.ini", "Recent Files", ($number-3), "ERR") $3rd = IniRead(@ScriptDir & "\config.ini", "Recent Files", ($number-2), "ERR") $2nd = IniRead(@ScriptDir & "\config.ini", "Recent Files", ($number-1), "ERR") $1st = IniRead(@ScriptDir & "\config.ini", "Recent Files", ($number), "ERR") GUICtrlCreateMenuitem($1st, $recentfilesmenu, 0) GUICtrlCreateMenuitem($2nd, $recentfilesmenu, 1) GUICtrlCreateMenuitem($3rd, $recentfilesmenu, 2) GUICtrlCreateMenuitem($4th, $recentfilesmenu, 3) $last = GUICtrlCreateMenuitem($5th, $recentfilesmenu, 4) ; #region ;bulk before decrypt file func While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exititem $checkstate = GUICtrlRead($tab0InputLevel) IniWrite((@scriptdir & "\config.ini"), "Settings", "Encryption Level", $checkstate) ExitLoop Case $msg = $tab0clear GUICtrlSetData($tab0EditText, "") Case $msg = $infoitem About() Case $msg = $tab0Copy $editdata = GUICtrlRead($tab0EditText) ClipPut($editdata) Case $msg = $tab0Cut $editdata = GUICtrlRead($tab0EditText) ClipPut($editdata) GUICtrlSetData($tab0EditText, "") Case $msg = $tab0Paste ;~ $checkstate = GUICtrlRead($tab0check); 4 is unchecked and 1 is checked $checkstate = IniRead((@scriptdir & "\config.ini"), "Settings", "Clear Before Paste", 1) If $checkstate = 4 Then $clipdata = ClipGet() $editdata = GUICtrlRead($tab0EditText) GUICtrlSetData($tab0EditText, ($editdata & $clipdata)) EndIf If $checkstate = 1 Then $clipdata = ClipGet() GUICtrlSetData($tab0EditText, $clipdata) EndIf Case $msg = $infoitemn Info() Case $msg = $tab1encrypt EncryptFile() Case $msg = $tab1decrypt DecryptFile() Case $msg = $tab0EncryptButton EncryptText() Case $msg = $tab0DecryptButton DecryptText() Case $msg = $settingsitem Settings() Case $msg = $tab2openimg OpenImg() Endselect WEnd Exit Func Settings() ;GUI GUICreate("Encrypt0r - Settings", 400, 300, -1, -1, -1, -1) GUICtrlCreateLabel("Default Directory When Encrypting\Decrypting:", 10, 20) $definput = GUICtrlCreateInput("Default Directory", 10, 35, 380, -1, $ES_READONLY) $changedir = GUICtrlCreateButton("Change...", 310, 60, 80, 25) $check = GUICtrlCreateCheckbox("Clear Text Before Pasting", 10, 85) $clearlist = GUICtrlCreateButton("Clear File Log", 10, 110, 80, 25) $deletefiles = GUICtrlCreateButton("Delete Logged Files", 95, 110, 110, 25) $slider = GUICtrlCreateSlider (10,135,380,40, $TBS_NOTICKS) $timelabel = GUICtrlCreateLabel("", 10, 160, 60) GUICtrlSetLimit($slider,5000,2000) ; change min/max value ;Load Settings $checked = IniRead((@scriptdir & "\config.ini"), "Settings", "Clear Before Paste", 1) If $checked = 1 Then GUICtrlSetState($check, $GUI_CHECKED);4 is unchecked and 1 is checked If $checked = 4 Then GUICtrlSetState($check, $GUI_UNCHECKED);4 is unchecked and 1 is checked $defdir = IniRead((@scriptdir & "\config.ini"), "Settings", "Default Directory", "C:\") $time = IniRead((@scriptdir & "\config.ini"), "Settings", "Splash Time", "5000") GUICtrlSetData($definput, $defdir) GUICtrlSetData($slider,$time) GUICtrlSetData($timelabel, $time & " Ms") GUISetState() While 1 $time = GUICtrlRead($slider) GUICtrlSetData($timelabel, $time & " Ms") $msg2 = GUIGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE $checkstate = GUICtrlRead($check) IniWrite((@scriptdir & "\config.ini"), "Settings", "Clear Before Paste", $checkstate) ExitLoop Case $msg2 = $changedir $defdir = FileSelectFolder("Choose the root folder when encrypting/decrypting files", "", 1 + 2 + 4) IniWrite((@scriptdir & "\config.ini"), "Settings", "Default Directory", $defdir) $defdir = IniRead((@scriptdir & "\config.ini"), "Settings", "Default Directory", "C:\") GUICtrlSetData($definput, $defdir) Case $msg2 = $clearlist $delete = MsgBox(48 + 4, "Warning!!", "Are you sure you want to delete the log of all encrypted files?") If $delete = 6 Then IniWrite((@scriptdir & "\config.ini"), "Settings", "NumOfFiles", 0) FileDelete((@scriptdir & "\Files.log")) EndIf Case $msg2 = $deletefiles DeleteFiles() Case $msg2 = $slider $time = GUICtrlRead($slider) IniWrite((@scriptdir & "\config.ini"), "Settings", "Splash Time", $time) EndSelect WEnd GUIDelete() EndFunc Func DeleteFiles() $i = 0 Do $i = $i + 1 $file = IniRead((@scriptdir & "\Files.log"), "Encrypted Files", $i, "END") If $file = "END" Then ExitLoop EndIf $deletepath = $file & ".encrypt" $result = FileDelete($deletepath) Until $i = 1000000 MsgBox(0, "Remember!", "Please Clear the Log File") EndFunc Func About() GUICreate("Encrypt0r - About", 400, 250, -1, -1, -1, -1, $GUI) $text = GUICtrlCreateLabel("Developed by Frazer McLean. If anyone would like to view the source code, PM me (RazerM) on the AutoIt forums for the passphrase to decompile. I would like to thank all the people who helped me.", 10, 170, 380, 70) $ver = GUICtrlCreateLabel("Version 0.3", 340, 230) $Logo = GUICtrlCreatePic(@ScriptDir & "\Encrypt0r.jpg", 0, 0, 400, 160) GUISetState() While 1 $msg2 = GUIGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc Func Info() GUICreate("Encrypt0r - Info", 400, 250, -1, -1, -1, -1, $GUI) $text = GUICtrlCreateLabel("Uses some code found in the AutoIt Help Manual. If you find a bug, please PM me (RazerM) on AutoIt forums or contact me at the following email address - frazergmclean@gmail.com." & @CR & "Note that encrypted files will not show up on the file log if moved directory, the same goes for the key if saved.", 10, 170, 380, 70) $ver = GUICtrlCreateLabel("Version 0.3", 340, 230) $Logo = GUICtrlCreatePic(@ScriptDir & "\Encrypt0r.jpg", 0, 0, 400, 160) GUISetState() While 1 $msg3 = GUIGetMsg() Select Case $msg3 = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc Func OpenImg() $filename = FileOpenDialog("Choose File to Decrypt", $dir, "Image Files (*.bmp.encrypt;*.jpg.encrypt;*.gif.encrypt)", "1") If @error <> 1 Then Dim $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit ($filename, $szDrive, $szDir, $szFName, $szExt) $copy = "C:\Temp\" & $szFName & $szExt $Ext = StringRight($szFName, 4) $move = "C:\Temp\pic" & $Ext FileCopy($filename, $copy) FileMove($copy, $move, 1) $keyexist = IniRead(@ScriptDir & "\config.ini", "File Key", $filename, "NOTEXIST") If $keyexist <> "NOTEXIST" Then $pass = _StringEncrypt(0, $keyexist, "Encrypt0r", 2) MsgBox(0, "Key Found!", "Key found! Encrypt0r will use it.") EndIf If $keyexist = "NOTEXIST" Then $pass = InputBox("Key", "Please enter the key used to encrypt this image.");Max 128 chars EndIf If $pass = "" Then MsgBox(48, "Decryption Aborted", "No key entered and key not found.. Try Again") EndIf If $pass <> "" Then $mode = "-";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa. Run(@ComSpec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move), "", @SW_HIDE) EndIf If @error <> 1 Then GUICtrlCreateMenuItem($filename, $recentfilesmenu) Sleep(2000) $aSize = _ImageGetSize($move) $ratio1 = $aSize[1]/$aSize[0] $ratio2 = $aSize[0]/$aSize[1] $differentdimensions = 0 If $aSize[0] > $aSize[1] Then While $aSize[0] > (@DesktopWidth - 10) Or $aSize[1] > (@DesktopHeight - 64) $aSize[0] = $aSize[0] - 10 $aSize[1] = $ratio1 * $aSize[0] $differentdimensions = 1 WEnd If $differentdimensions = 1 Then MsgBox(0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1]) EndIf If $aSize[1] > $aSize[0] Then While $aSize[1] > (@DesktopHeight - 64) Or $aSize[0] > (@DesktopWidth - 10) $aSize[1] = $aSize[1] - 10 $aSize[0] = $ratio2 * $aSize[1] $differentdimensions = 1 WEnd If $differentdimensions = 1 Then MsgBox(0, "Picture Too Large", "Resized to " & $aSize[0] & "x" & $aSize[1]) EndIf GUICreate("Encrypt0r - Image Viewer", $aSize[0], $aSize[1], -1, -1, -1, -1, $GUI) GUICtrlCreatePic($move, 0, 0, $aSize[0], $aSize[1]) FileDelete($move) GUISetState() While 1 $msg3 = GUIGetMsg() Select Case $msg3 = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndIf EndFunc ;==>OpenImg #endregion Func DecryptFile() $filename=FileOpenDialog("Choose File to Decrypt", $dir, "Encrypted Files (*.encrypt)", "1") If @error <> 1 Then Dim $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt) $savefile=FileSaveDialog("Choose Where to Save Decrypted File", ($szDrive & $szDir), "All Files (*.*)", 0, $szFName) If @error <> 1 Then Dim $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext $TestPath = _PathSplit($savefile, $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext) $copy="C:\Temp\" & $szFName & $szExt $szFExt = StringRight($szFName, 4) $move=$sz2Drive & $sz2Dir & $sz2FName & $szFExt FileCopy($filename, $copy) FileMove($copy, $move, 1) $keyexist = IniRead(@ScriptDir & "\config.ini", "File Key", $filename, "NOTEXIST") If $keyexist <> "NOTEXIST" Then $pass = _StringEncrypt(0, $keyexist, "Encrypt0r", 2) MsgBox(0, "Key Found!", "Key found! Encrypt0r will use it.") EndIf If $keyexist = "NOTEXIST" Then $pass = InputBox("Key", "Please enter the key used to encrypt this file.") ;Max 128 chars EndIf If $pass = "" Then MsgBox(48, "Decryption Aborted", "No key entered and key not found.. Try Again") EndIf If $pass <> "" Then $mode = "-";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa. Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide) $delete = MsgBox(4, "Delete Source File?", ("Would you like to delete " & $szFName & $szExt));6 is yes If $delete = 6 Then FileDelete($filename) EndIf If @error <> 1 Then $number = IniRead(@ScriptDir & "\config.ini", "Recent Files", "Number", 0) IniWrite(@ScriptDir & "\config.ini", "Recent Files",($number+1), $savefile) IniWrite(@ScriptDir & "\config.ini", "Recent Files","Number", ($number+1)) GUICtrlCreateMenuitem ($filename,$recentfilesmenu, 0) GUICtrlDelete($last) MsgBox(0, "Decrypted", "Decryption Complete") EndIf EndIf EndIf EndFunc Func EncryptFile() $filename=FileOpenDialog("Choose File to Encrypt", $dir, "All Files (*.*)", "1") If @error <> 1 Then Dim $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt) $path = $szFName & $szExt $savefile=FileSaveDialog("Choose Where to Save Encrypted File", ($szDrive & $szDir), "Encrypted Files (*.encrypt)", 0, ($szFName & $szExt & ".encrypt")) If @error <> 1 Then $encrypt = ".encrypt" Dim $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext $TestPath = _PathSplit($savefile, $sz2Drive, $sz2Dir, $sz2FName, $sz2Ext) $FNamecheck = StringRight($sz2FName, 4) $FNamecheck2 = StringRight($sz2FName, 12) $FNamecheck3 = StringLeft($FNamecheck2, 4) $sz3Ext = $szExt If $FNamecheck = $szExt Then $szExt = "" If $FNamecheck = "rypt" Then $encrypt = "" If $FNamecheck3 = $szExt Then $szExt = "" $copy="C:\Temp\" & $szFName & $szExt $move=$sz2Drive & $sz2Dir & $sz2FName & $szExt & $encrypt $inidir=$sz2Drive & $sz2Dir & $sz2FName & $szExt FileCopy($filename, $copy) FileMove($copy, $move, 1) $num = IniRead((@scriptdir & "\config.ini"), "Settings", "NumOfFiles", "ERROR") $num = $num + 1 IniWrite((@scriptdir & "\Files.log"), "Encrypted Files", $num, $inidir) IniWrite((@scriptdir & "\config.ini"), "Settings", "NumOfFiles", $num) $pass = InputBox("Key", "Please enter the key to be used for encryption") ;Max 128 chars If $pass = "" Then MsgBox(48, "Warning!", "No key entered!! 'default' will be used as the key!") $pass = "default" EndIf $mode = "+";or "-" usually + is used for encrypt, - for decrypt but it can be vice versa. Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide) $delete = MsgBox(4, "Delete Source File?", ("Would you like to delete " & $path));6 is yes If $delete = 6 Then FileDelete($filename) GUICtrlCreateListViewItem(($szFName & "|" & $sz3Ext & "|" & $inidir & ".encrypt"), $tab1list) $savekey = MsgBox(4, "Save Key?", "Would you like to save the key?" & @LF & "CAUTION! Anyone will be able to decrypt the file if they have your config.ini!") If $savekey = 6 Then $encryptedkey = _StringEncrypt(1, $pass, "Encrypt0r", 2) IniWrite(@ScriptDir & "\config.ini", "File Key", $move, $encryptedkey) EndIf MsgBox(0, "Encrypted", "Encryption Complete") If @error <> 1 Then GUICtrlCreateMenuitem ($filename,$recentfilesmenu) EndIf EndIf EndFunc Func DecryptText() $key = GUICtrlRead($tab0InputPass) If $key = "" Then MsgBox(48, "Error!", "Key cannot be left blank!") If $key <> "" Then $level = GUICtrlRead($tab0InputLevel) If $level > 10 Then $level = 10 GUICtrlSetData($tab0InputLevel, 10) EndIf GuiSetState(@SW_DISABLE,$GUI) ; Stops you from changing anything $string = GuiCtrlRead($tab0EditText) ; Saves the editbox for later GUICtrlSetData($tab0EditText,'Decryption In Progress, Please Wait') ; Friendly message GuiCtrlSetData($tab0EditText,_StringEncrypt(0,$string,GuiCtrlRead($tab0InputPass),$level)) GuiSetState(@SW_ENABLE,$GUI) ; This turns the window back on EndIf EndFunc Func EncryptText() $key = GUICtrlRead($tab0InputPass) If $key = "" Then MsgBox(48, "Error!", "Key cannot be left blank!") If $key <> "" Then $level = GUICtrlRead($tab0InputLevel) If $level > 10 Then $level = 10 GUICtrlSetData($tab0InputLevel, 10) EndIf GuiSetState(@SW_DISABLE,$GUI) ; Stops you from changing anything $string = GuiCtrlRead($tab0EditText) ; Saves the editbox for later GUICtrlSetData($tab0EditText,'Encryption In Progress, Please Wait') ; Friendly message GuiCtrlSetData($tab0EditText, _StringEncrypt(1,$string,GuiCtrlRead($tab0InputPass),$level)) GuiSetState(@SW_ENABLE,$GUI) ; This turns the window back on EndIf EndFunc GUIDelete() Exit ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-END: C:\Documents and Settings\FrazerMcLean\My Documents\AutoIt\Encrypt0r\GUI9.au3> ; ---------------------------------------------------------------------------- Edited October 21, 2013 by Jos AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 7, 2006 Moderators Share Posted June 7, 2006 Wouldn't this one part (Guilty of not reading the whole code) Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide) be what he was looking for? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 AutoIt comes with a decompiler called Exe2Au3. I have done it for you: Script Thanks but i really don't have that decompiler, i only got Au32Exe Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 7, 2006 Moderators Share Posted June 7, 2006 Thanks but i really don't have that decompiler, i only got Au32ExeLook in your Extra Folder, and you will be :D Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 Wouldn't this one part (Guilty of not reading the whole code) Run(@comspec & " /c echo " & $pass & "|encrypt.com " & $mode & " " & FileGetShortName($move),"",@sw_hide) be what he was looking for? What the h*ll???????????? Is he hacking me now??? He was opening command.exe + writing echo <mypass>|encrypt.com (this website doesn't exist, except www.encrypt.com) + "Encrypt File (+) " + short file name.... Doesn't make sense?? ----- But onTopic, still don't know he had done it He has a very irritating way of writing his syntaxes... -ImMenSe Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 I just know why i couldn't find it.........omg... this is lame, are you ready to know how he did the 'incredible' thing!?He changed the name of a 'ENCRYPTED' file into .encrypt,You still don't understand what im telling you right now, so here's an exampleLamePic.JPG gets encrypted by the 'Encrypt0r' program.. and the only thingwhat the silly program does is that he changes the name LamePic.JPG into LamePic.JPG.Encryptwell if you change the name back again to LamePic.JPG, the picture shows it again without getting 'really' encrypted That's lame.........So this program didn't actually help..Look in your Extra Folder, and you will be Lol, you're right ..hehehehee It reappeared!!Oh yeah, does anybody else know how to really ENCRYPT a JPG?-ImMenSe Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 7, 2006 Moderators Share Posted June 7, 2006 What the h*ll????????????Is he hacking me now???He was opening command.exe + writing echo <mypass>|encrypt.com (this website doesn't exist, except www.encrypt.com) + "Encrypt File (+) " + short file name....Doesn't make sense??-----But onTopic, still don't know he had done it He has a very irritating way of writing his syntaxes...-ImMenSeNow that's just being absurd... and his syntax is fine, very easy to understand if you take the time to actually look... $pass was the key you used to encypt it to begin with. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Immensee Posted June 7, 2006 Author Share Posted June 7, 2006 Ehm, okay You could understand it but i don't:P I am stupid and you're not But how is it possible to encrypt a IMAGE? -ImMense Link to comment Share on other sites More sharing options...
Micha1405 Posted June 7, 2006 Share Posted June 7, 2006 Try it with IDEA ftp://ftp.ox.ac.uk/pub/crypto/misc/idea86.zipa sample you find in this forum http://www.autoitscript.com/forum/index.ph...76entry149276 My TrayToolBar Link to comment Share on other sites More sharing options...
RazerM Posted June 7, 2006 Share Posted June 7, 2006 it doesnt rename it, encrypt.com is a file that uses command paramaters to encrypt a file, if you don't have it, it wont encrypt it. Check out my IDEA file encryption UDF. It's in my signature. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
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