Jump to content

One Time Pad Algorhitym


Recommended Posts

Lookup help for fileopen in binary mode. Read chunks of bytes, perform your xor and write.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Open input in binary mode

open output in binary mode

read a byte

if eof exitloop

xor with corresponding byte in pad

write result

loop

Hexadecimal is simply a "human-friendly" representation of data. You can display data in hex, octal, ASCII, UTF, whatever suits the need for you to comprehend it. Displaying data under one form or another doesn't change it but some forms give you a better understanding/readability. E.g. displaying text in hex isn't particularly easy to read.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

You really should google about things you don't understand.

Look: say you have a file wich contents the string AB3. Ok this is one representation, suited to human eyes and brain.

This ASCII string translates into hex as 41 42 33. This is a second representation, somehow less readable but your brain can still get it if you look at an ASCII table.

In octal, you obtain 101 102 063. This is a fourth representation of the same string. Somehow unusual and much less readable.

In binary, this is 01000001 01000010 00110011. This is a fourth representation of the very same data. Even if you can "read" the series of 0 and 1, it's now much harder to understand that these bits mean AB3.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Thanks for the explanation, but is non this the thing that I don't understand.. I am googling but I can't find a solution:

If I take a byte from a Hex string, let's say "A", how can I XOR this byte? (BitXOR doesn't XOR letters)..

I could transform it in ASCII, but the variable number of digits is a problem when decoding..

Link to comment
Share on other sites

This ASCII string translates into hex as 41 42 33

so work with that

$string = "AB3"
$Sarray = stringsplit($string , "" , 2)

for $i = 0 to ubound($Sarray) - 1
    $bin = stringtrimleft(binary($Sarray[$i]) , 2)
$Sarray[$i] = $bin
Next

$xor = BitXOR($Sarray[0] , $Sarray[1] , $Sarray[2])

msgbox (0, '' , $Xor)
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Thanks, following your example I tried this:

$ID = FileOpen($File, 16)
                $File = StringSplit(StringToBinary(StringTrimLeft(FileRead($ID), 2)), "")
                FileClose($ID)
                $ID = FileOpen($Chiave, 16)
                $Chiave = StringSplit(StringToBinary(StringTrimLeft(FileRead($ID), 2)), "")
                FileClose($ID)
                If $Chiave[0] < $File[0] Then
                    MsgBox(16, "Errore", "La chiave è troppo corta.")
                Else
                    For $a = 3 To $File[0] Step 1
                        $File[$a] = BitXOR($File[$a], $Chiave[$a])
                    Next
                    $File = "0x" & BinaryToString(_ArrayToString($File, "", 1))
                    $ID = FileOpen($NewFile, 18)
                    FileWrite($ID, $File)
                    MsgBox(64, "Info", "Operazione completata con successo.")
                EndIf

But doesn't work.. the file isn't decrypted and becomes unreadable.

Edited by LordBlackout
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...