Encryption program, help..

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
jj45410
Junior Coder
Posts: 38
Joined: Tue Nov 18, 2008 8:14 pm

Encryption program, help..

Post by jj45410 » Tue Dec 16, 2008 10:55 pm

Hi guys.. I want to make my own little simple encryption program using base64, well.. I really do not know where to start I have a basic idea which is create a menu, and then a box appears where you would type in the file name of what you want to encrypt and then click a button for encryption or decryption, Well :/ I honestly do not know where to even begin.. so something like this would be the subroutine.

Crypt>abc,(what I want encrypted, is it like a %% or something),Encryptl
Base64>Encrypt,ENCODE,ascii_Encrypt
WriteLn>c:\(target file).txt,r,ascii_Encrypt
and is what I want to be the subroutine, and THEN a search bar of some kind, kinda like when you click start -> run it has that sorta serach bar, well that but a button next to it saying encrypt or decrypt (I know I've already said half of this) Could someone please start me in the right direction, Thank you - jj45410

User avatar
JRL
Automation Wizard
Posts: 3505
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Dec 17, 2008 5:26 am

I posted a script to encrypt a line of text entered into a dialog a couple of years ago. You can find it here. Hopefully it can get you pointed in a direction.

If you are encrypting text, you don't need to also encode it using base64. You can if you want but it sounds like overkill. I don't think I'd bother with it unless you have some need to base64 encode the encryption for inclusion in some other software.

Simon_Slater
Newbie
Posts: 7
Joined: Thu Oct 16, 2008 4:43 pm

Post by Simon_Slater » Wed Dec 17, 2008 7:38 pm

Not sure if this will help, it's something I knocked up to do some password encryption that I needed.

You'll need to change the encrytion key used. This is the line Crypt>EncStrg,PwEntered1,PwCrypt. The script is not perfect but it did the job for me.

Code: Select all

// Set up for Script
// Input Type Set to Password
Let>INPUT_PASSWORD=1
// Set Encryption to HIGH
Let>CRYPT_LEVEl=3

//Variable to exit if pw not matched 3 times
Let>InputLoop=0

// Main
GoSub>Input-Pass

Label>Check-Matched
// Check Password are the same
Length>%PwEntered1%,PWLength
If>%PWLength%=0,BlankPW,PWLenOK
Label>PWLenOK
If>%PwEntered1%=%PwEntered2%,PWEncrypt,PWNotMatched

//Basic Loop to Ask for Password input again.
Label>PWNotMatched
If>%InputLoop%=3
  MessageModal>Password Have Not Matched 3 Times - Exiting...%CRLF%Click OK.
  Exit>
EndIf
MessageModal>The Passwords Did Not Match.%CRLF%%CRLF%Please Click OK and Renter the Password.
GoSub>Input-Pass
Goto>Check-Matched

Label>BlankPW
MessageModal>The Password Cannot be Blank.%CRLF%%CRLF%Please Click OK and Renter the Password.
GoSub>Input-Pass
Goto>Check-Matched

// Encrypt the Password
Label>PWEncrypt
Crypt>EncStrg,PwEntered1,PwCrypt
Let>PwEntered1=Null
Let>PwEntered2=Null
// Change Input Type to Normal Text
Let>INPUT_PASSWORD=0

// Get the Location to Save the File.
Input>FileLocation,Enter The Location to Save the File:,C:\Documents and Settings\%USER_NAME%\My Documents\pwencrypted.txt
If>%FileLocation%=
  Message>Cancel Button Pushed or Field Left Blank, Exiting....
  Wait>2
  IfWindowOpen>Macro Scheduler Message
    CloseWindow>Macro Scheduler Message
  EndIf
  Exit>
Else
  // Encode the Text with Base64
  Base64>PwCrypt,ENCODE,PWEncoded
  // Write Encrypted and Encoded PW to File.
  WriteLn>%FileLocation%,Res,PWEncoded
  MessageModal>Password Encrpyted and Written to File:%CRLF%%Filelocation%.
  // Test Code
  // ReadLn>%FileLocation%,1,TextRead
  // Base64>TextRead,DECODE,decoded
  // MessageModal>%decoded%
  // Crypt>EncStrg,decoded,unenc
  // MessageModal>%unenc%
Endif
Exit>

//SRT's
//Ask for Password Sub Routine.
SRT>Input-Pass
Input>PwEntered1,Please Enter the Password to be Encrypted,
Input>PwEntered2,Please Renter the Password to be Encypted,
Let>InputLoop=%InputLoop%+1
End>Input-Pass
Hope this helps you on your way.

Simon.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts