Jump to content

Vault - A password protected edit


Achilles
 Share

Recommended Posts

This is a very simple program, but I also think it's very secure. What it does is let you create a password. Then, you can type in the edit. When you exit, it appends the text in the edit to the end of your au3 file, encrypted. Next time you open the file, you have to insert the password to be able to view your text.

Note: This doesn't work when compiled. I might try adding something to change that later.. which would be pretty sweet.

Unless I'm mistaken it's pretty much impossible to view the files unless you know the password. You would have to decode the _StrinEncrypt function...

If you want a more complex encryption you can only change that before you create a password (you change the constant at the top of the file). If you try changing it after it will be trying to decrypt your text with a different level of encryption that it was originally encrypted with.

Don't modify the au3 file, if you add an ';' anywhere (at the start of a line) apart from the end of the code it will cause errors.

Let me know what you think.

#Include <File.au3>
#include <String.au3>

Global Const $PATH = @ScriptFullPath
Global Const $ENCRYPT_LEVEL = 1

Global $maxLines = _FileCountLines($PATH)
Global $passCrypt

$firstTime = _CheckFirst()

If $firstTime then 
    $passCrypt = InputBox('Vault', 'Welcome to Vault. Please create a password.', '', '*', 300, 140)
    
    If $passCrypt = '' then Exit 
    $text = ''
Else 
    $passCrypt = InputBox('Vault', 'Welcome to Vault. Please enter your password.', '', '*', 300, 140) 
    If $passCrypt = '' then Exit
    
    $text = ''
    $file = FileOpen($path, 0) 
    $index = $maxLines 
    
    $temp = StringStripWS(FileReadLine($file, $index) , 8)

    While StringLeft($temp, 1) = ';' 

        $text = _StringEncrypt(0, StringTrimLeft($temp, 1), $passCrypt, $ENCRYPT_LEVEL) & @CRLF & $text 
        $index -= 1
        $temp = StringStripWS(FileReadLine($file, $index) , 8) 
    WEnd
    FileClose($file)
EndIf 

GUICreate('Vault', 500, 400)
$hEdit = GUICtrlCreateEdit($text, 5, 5, 490, 390)
GUISetState()

Do 
Until GuiGetMsg() = -3 

$file = FileOpen($path, 0) 
$origText = ''
$indexFor = 1
$temp = FileReadLine($file, $indexFor) 
While StringLeft($temp, 1) <> ';' and $indexFor <= $maxLines 
    $origText &= $temp & @CRLF 
    $indexFor += 1
    $temp = FileReadLine($file, $indexFor) 
WEnd 
FileClose($file)

$file = FileOpen($path, 2) 
FileWrite($file, $origText) 
FileWrite($file, @CRLF)

$editText = GUICtrlRead($hEdit)
$array = StringSplit($editText, @CRLF) 
For $i = 1 to $array[0]
    
    $temp = _StringEncrypt(1, $array[$i], $passCrypt, $ENCRYPT_LEVEL)
    FileWriteLine($file, ';' & $temp)
Next 

Func _CheckFirst() 
    $file = FileOpen($PATH, 0)

    For $i = $maxLines to 0 Step -1
        $temp = StringStripWs(FileReadLine($file, $i), 8)

        If StringLen($temp > 0) then 
            FileClose($file)
            Return Not (StringLeft($temp, 1) = ';')
        EndIf           
    Next 
EndFunc
Edited by Ichigo
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

hi,

it think it's pretty nice..

but it's not working correct for me..

if you create a pass & text, and then u insert a wrong pass it is unreadable indeed.. but if you then insert the right pass it still is unreadable.. so it protects indeed, but you will lose your text in the process.

so maybe it's not totally complete :)

Link to comment
Share on other sites

hi,

it think it's pretty nice..

but it's not working correct for me..

if you create a pass & text, and then u insert a wrong pass it is unreadable indeed.. but if you then insert the right pass it still is unreadable.. so it protects indeed, but you will lose your text in the process.

so maybe it's not totally complete :)

Aah, yes... I really shouldn't release program late at night just after finishing them... I never think about how they could go wrong. I'll fix that sometime soon.
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...