DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Idea: Simple Key Text Encryption Program  (Read 5,963 times)

workinprogress

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
Idea: Simple Key Text Encryption Program
« on: January 26, 2009, 08:17 AM »
Basically I am looking for a program that you can encrypt and decrypt text on the fly with using a key. I would like to work where you enter a key and a coded or decoded message and it would code or decode it.

workinprogress

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
Re: Idea: Simple Key Text Encryption Program
« Reply #1 on: January 26, 2009, 08:22 AM »
Also I was planning to use it when group instant messaging, posting certain things on certain websites, and emailling over unsecured networks.

aCkRiTe

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 21
Re: Idea: Simple Key Text Encryption Program
« Reply #2 on: January 26, 2009, 04:36 PM »
Not exactly sure if this is what you're looking for, but I thought I'd post it. So basically this is an RC4 encryption that I used from http://www.autohotkey.com/forum/topic598.html&highlight=rc4.

How it works:
1. run the script (it can be left running at all times)
2. when you want to encrypt something simply copy the text to the clipboard and then fire the hotkey (ctrl + alt + z)
3. you will be prompted to enter a password which is used for the encryption
4. once you enter a password your text will then be encrypted and then placed back to the clipboard.
5. send your encrypted text to someone that has the same script
6. they place the encrypted text to the clipboard and fire the hotkey (ctrl + alt + z)
7. they have to enter the same password you used to encrypt the text
8. the text will then be decrypted and the original text that you wrote will be placed to the clipboard

AHK
Code
SingleInstance Force
#Persistent
#NoEnv
SetBatchLines, -1

^!x::
Password:
InputBox, PW, Password, Enter a password., , 200, 125
If ErrorLevel <> 0
	ExitApp
If PW = 
	Goto, Password
Data = %Clipboard%
Gosub, RC4
Clipboard = %Result%
Return

RC4:
ATrim = %A_AutoTrim%
AutoTrim, Off
BLines = %A_BatchLines%
SetBatchlines, -1
StringLen, PWLen, PW
IfNotEqual, PW, %OldPW%
	{
		Loop, 256
			{
				a := A_Index - 1
				Transform, ModVal, Mod, %a%, %PWLen%
				ModVal ++
				StringMid, C, PW, %ModVal%, 1
				Transform, AscVar, Asc, %C%
				Key%a% = %AscVar%
				sBox%a% = %a%
			}
		b = 0
		Loop, 256
			{
				a := A_Index - 1
				TempVar := b + sBox%a% + Key%a%
				Transform, b, Mod, %TempVar%, 256
				T := sBox%a%
				sBox%a% := sBox%b%
				sBox%b% = %T%
			}	
	
		OldPW = %PW%
	}
StringLen, DataLen, Data
Result =
i = 0
j = 0
Loop, %DataLen%
	{
		TmpVar := i + 1
		Transform, i, Mod, %TmpVar%, 256
		TmpVar := sBox%i% + j
		Transform, j, Mod, %TmpVar%, 256
		TmpVar := sBox%i% + sBox%j%
		Transform, TmpVar2, Mod, %TmpVar%, 256
		k := sBox%TmpVar2%
		StringMid, TmpVar, Data, %A_Index%, 1
		Transform, AscVar, Asc, %TmpVar%
		Transform, C, BitXOR, %AscVar%, %k%
		IfEqual, C, 0
			C = %k%
		Transform, ChrVar, Chr, %C%
		Result = %Result%%ChrVar%
	}
AutoTrim, %ATrim%
SetBatchlines, %BLines%
Return
GuiClose:
ExitApp

workinprogress

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
Re: Idea: Simple Key Text Encryption Program
« Reply #3 on: January 26, 2009, 10:05 PM »
This is exactly what I was looking for! Thank you so much!

Original address: https://www.donationcoder.com/forum/index.php?topic=16757.0