Jump to content

Unbreakble Encryption


DaProgrammer
 Share

Recommended Posts

The only Encryption method that is mathematicly proven to be unbreakble !

For explenation on how the method works go to wiki.

One-time pad on Wikipedia

basicly u and the reciever must have the same key file.

to test generate a key and copy,paste it then encrypt with 1 copy and decrypt with the second.

not perfect yet but u gotta try this :)

#include <GuiConstants.au3>
#include <Array.au3>
#include <File.au3>
;
$Orig = ""
$dest = ""
$i = 0
$count = 0
$progress = 0
$progress_L = 0
$key_path = ""
$a = ""

Opt("GUIOnEventMode",1)
;
#region - Main
GuiCreate("KJ's Ultimate Encryption", 700, 500,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Edit_Orig = GuiCtrlCreateEdit("Enter the text u want to Encrypt/Decrypt here", 10, 10, 300, 480)
GUICtrlSetLimit($Edit_Orig,30000)
$Edit_Dest = GUICtrlCreateEdit("Push the button and see the result here", 390, 10, 300, 480)
GUICtrlSetLimit($Edit_Dest,30000)
$Button_Encrypt = GuiCtrlCreateButton("Encrypt -->", 320, 10, 60, 30)
GUICtrlSetOnEvent($Button_Encrypt,"Encrypt")
$Button_Decrypt = GuiCtrlCreateButton("Decrypt -->", 320, 50, 60, 30)
GUICtrlSetOnEvent($Button_Decrypt,"Decrypt")
GUICtrlCreateLabel("<--",310,120,15,15,$ss_center)
GUICtrlCreateLabel("-->",375,100,15,15,$ss_center)
$Chr_L = GUICtrlCreateLabel("0",330,120,40,15,$ss_center)
$Chr_L2 = GUICtrlCreateLabel("0",330,100,40,15,$ss_center)
$progress_L = GUICtrlCreateLabel("0%",330,200,40,15,$ss_center)
$progress = GUICtrlCreateProgress(340,220,15,200,BitOR($PBS_VERTICAL,$PBS_SMOOTH))
$Input_Key = GUICtrlCreateInput("15",320, 430, 40, 20,$ES_NUMBER)
GUICtrlCreateLabel("KB",365, 433, 20, 20)
$Button_Key = GuiCtrlCreateButton("Generate        Key", 320, 460, 60, 30,$BS_MULTILINE)
GUICtrlSetOnEvent($Button_Key,"Key")

GuiSetState()
GUISetOnEvent($GUI_EVENT_CLOSE,"Exitt")
;
While 1
GUICtrlSetData($Chr_L,StringLen(GUICtrlRead($Edit_Orig)))
GUICtrlSetData($Chr_L2,StringLen(GUICtrlRead($Edit_Dest)))
Sleep(1000)
WEnd
#endregion
;
Func Encrypt()
    $key_path = FileOpenDialog("Select Key File to Encrypt with",@ScriptDir,"KJ Key File (*.kjk)",3)
    If $key_path = "" Then Return
    $dest = ""
    $Orig = GUICtrlRead($Edit_Orig)
    $File = FileOpen($key_path,32)
    $key = FileRead($File)
    FileClose($File)
    $count = StringLen($Orig)
    for $i = 1 To $count
        $dest2 = Chrw( Mod(Ascw(StringMid($Orig,$i,1))+(Ascw(StringMid($key,$i,1))),65535))
        $dest = $dest & $dest2
        Setp($i/$count*100)
    Next
    Setp(0)
    GUICtrlDelete($Edit_Dest)
    $Edit_Dest = GUICtrlCreateEdit("", 390, 10, 300, 480)
    GUICtrlSetData($Edit_Dest,$dest,"Eror")
    $key = StringTrimLeft($key,$count)
    
    $File = FileOpen($key_path,34)
    FileWrite($File,$key)
    FileClose($File)
    $key_path = ""
    
EndFunc
;
Func Decrypt()
    $key_path = FileOpenDialog("Select Key File to Decrypt with",@ScriptDir,"KJ Key File (*.kjk)",3)
    If $key_path = "" Then Return
    $dest = ""
    $Orig = GUICtrlRead($Edit_Orig)
    $File = FileOpen($key_path,32)
    $key = FileRead($File)
    FileClose($File)
    $count = StringLen($Orig)
    for $i = 1 To $count
        $dest2 = Chrw( Mod(Ascw(StringMid($Orig,$i,1))-(Ascw(StringMid($key,$i,1))),65535))
        $dest = $dest & $dest2
        Setp($i/$count*100)
    Next
    Setp(0)
    GUICtrlDelete($Edit_Dest)
    $Edit_Dest = GUICtrlCreateEdit("", 390, 10, 300, 480)
    GUICtrlSetData($Edit_Dest,$dest,"Eror")
    $key = StringTrimLeft($key,$count)
    
    $File = FileOpen($key_path,34)
    FileWrite($File,$key)
    FileClose($File)
    $key_path = ""
EndFunc
;
Func Key()
    $key_path = FileSaveDialog("Select a KJ Key File to write to",@ScriptDir,"KJ Key File (*.kjk)")
    
    If $key_path = "" Then Return
    $Path_temp = _PathSplit($key_path,$a,$a,$a,$a)
    If $Path_temp[4] <> ".kjk" Then $key_path = $key_path & ".kjk"
    
    $count = GUICtrlRead($Input_Key)*1024/2-1
    $key = ""
    
    $File = FileOpen($key_path,34)
    For $i = 1 to $count
        $key = ChrW(Random(1,65535,1))
        FileWrite($File,$key)
        Setp($i/$count*100)
    Next
    FileClose($File)
    setp(0)
    $key_path = ""
EndFunc
;
Func setp($z)
    If $z = 0 Then
        GUICtrlSetData($progress,0)
        GUICtrlSetData($progress_L,"0%")
    Else
        GUICtrlSetData($progress,$z)
        If Mod(Round($z,1),1) = 0 Then GUICtrlSetData($progress_L,Int($z) & "%")
    EndIf
EndFunc
;
Func Exitt()
    Exit
EndFunc
Link to comment
Share on other sites

To test this i generate a key.

I write something in the left edit and I press Encrypt. This gives something in the right edit which I assume is the encoded text.

I copy the text in the right edit and paste it into the left edit. I press decrypt and I get more illegible text in the right edit, but I expected to see my original text.

What should I be doing?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

To test this i generate a key.

I write something in the left edit and I press Encrypt. This gives something in the right edit which I assume is the encoded text.

I copy the text in the right edit and paste it into the left edit. I press decrypt and I get more illegible text in the right edit, but I expected to see my original text.

What should I be doing?

when u encrypt a text it deductes that number of chars from the key file so if u try to decode with the same key file it aint the same key.

u need to make 2 exactly the same keys (use Ctrl+C --> Ctrl+V) to simulate the 2 users chatting and then encrypt with 1 and decrypt with second.

Link to comment
Share on other sites

same as martin

can you make a simpli-er gui, i'm sure that your scripts works, i just don't manage to test it

seems really interesting

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

same as martin

can you make a simpli-er gui, i'm sure that your scripts works, i just don't manage to test it

seems really interesting

i didnt understand what u said but it semms people have a hard trouble figering how to use this so here's a Readme.txt i wrote

1. Generate a Key

Each character of your text needs 1 byte of "Key" so for 10,000 characters u need 1 KB of "Key". Meaning dont exadurate the key Size since it will take a long time to generate and a long time to load each time u Encrypt/Decrypt. For short messeges (100 Words x 5 Chars x 30 Days = 15KB) i reccomend about 15KB of key, it will last ~ a month if u plan to send/recieve larger Text than use a larger key.

2. Deliever the Key.

Make sure your penpal has the same key as u before u start sending messeges. I reccomend not sending the key over the net but delivering it personally, if u can't then Encrypt the key with an external program before sending.

3. Encrypt a message

Enter the Text u want to encrypt and press "Encrypt" make note that it will delete the used "Key Notes" from your key file, so this prosses can't be reverted.

4. Send the messege

Select the text output and send it by any means u want, without the key file or the original text there is a 0% chance of it being Decrypted by even the strongest computer on earth.

5. Decrypt a message

Same as step 3. Note that it will again remove the "Key Notes" from your key file so again be carefull since this prosses can't be reverted.

Happy Messaging :)

Notes :

* 1MB of key takes ~30 secs to generate so dont oversize your key.

* Always use "Unicode" when asked for Text Type.

* Keep a separate key for each penpal.

* If u cant Decrypt a message that was sent to you or your penpal can't then generate a new key and start over.

* When your "Key" file size = 0 then its time to generate a new key.

just in step 2 create a copy of the key file if u msg urself for testing

or in short :

1) generate a key and name it "1.kjk"

2) Ctrl+C --> Ctrl+V rename the copy to "2.kjk"

3)write some text and press encrypt, use "1.kjk"

4)copy the result to the left panel and press decrypt, use "2.kjk"

Edited by DaProgrammer
Link to comment
Share on other sites

  • 2 months later...

Oh, never say unbreakable <_< It is only so until it is broken :P

Yeah, I think I could use this in my secure chat-like prog. :)

The only thing is that there has to be an transfer of keys. This is (as said on the wiki) the most used flaw in the system.

BTW, and they don't understand that the generated key is destroyed on use. :)

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

Each character of your text needs 1 byte of "Key" so for 10,000 characters u need 1 KB of "Key".

You must not be able to do any math whatsoever. A kilobyte is 1024 bytes, not 10000.

Also, I made something like this for a project I wrote in high school. It was more efficient because you could encrypt using a string. That string could be longer or shorter than the source text, but it would repeat the string in a manner that prevented people from breaking it. It worked almost exactly the same as your script here, only easier.

Link to comment
Share on other sites

Each character of your text needs 1 byte of "Key" so for 10,000 characters u need 1 KB of "Key".

You must not be able to do any math whatsoever. A kilobyte is 1024 bytes, not 10000.

Also, I made something like this for a project I wrote in high school. It was more efficient because you could encrypt using a string. That string could be longer or shorter than the source text, but it would repeat the string in a manner that prevented people from breaking it. It worked almost exactly the same as your script here, only easier.

"A kilobyte is 1024 bytes, not 10000" --> i rounded LOL i know the KB is 1024 and not 1000

"but it would repeat the string" --> if the string is repeated that it can be broken! the point of the "one time pad" is that each character is encrypted by another random character. so theoretically u get endless possibilities of decrypted logical text.

BTW : if some1 knows that the KEY was created randomly by a computer thats enough to break it <_< the CPU's "Random" isn't a real random and is dependand on your CPU clock speed.

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...