Encrypt / bDecrypt issues

Blitz3D Forums/Blitz3D Programming/Encrypt / bDecrypt issues

_33(Posted 2007) [#1]
LOOKUP TABLE CODE
===============

The issue is that something is miscalculated when encrypting/decrypting, and I can't seem to see that.



Any help appreciated.


_33(Posted 2007) [#2]
My solution, 2 tables... And 2 seperate functions (Encrypt / Decrypt)... :(



I tought I could make it simpler. In fact, to make this simpler, I would have to swap 2 values, making it a 128 byte encryption key, which would give the answer in the next 128 bytes. That would be really bad! Actually, making a reverse reference from the table seems the logical way of doing this. But for the solution proposed here, I'll try to see if it is possible to not have a cross reference table and just try to compute that out... I'm just a little hazed out on this sort of thing!


_33(Posted 2007) [#3]
Still some issues. Found out that the small loop to find unique entries in the table is bogus, actually, one of the entries is missing and there is one duplicate created on the first table. The second table decides to create a zero entry (which is missing from the first table)... I'm still trying to find what is happening and finding a solution here. I've got another way of creating the table, but it's got an infinite loop in that and I haven't figured that one out either! Intense!



EDIT: OK, I know what the problem is finally. Since a bank when initialized contains zero byte values across, it does an infinite loop as soon as it maches what the random value is versus a zero when the random value is zero. So I'll have to change my tactics a bit.

So here's the final solution, which seems to give 256 unique values:



big10p(Posted 2007) [#4]
I see you're altering a loop variable (j) inside the loop itself. I always thought that was a no-no? Maybe it is ok, though - if it works, it works.


_33(Posted 2007) [#5]
Actually big10p, that's a false logic, as the counter will skip 0. Better avoid this to make sure you don't fall into some logic traps. The last example is the one that should work for 100% of cases.


big10p(Posted 2007) [#6]
Ah, yes - I knew it was dodgy. I guess you could have set j to -1 instead of 0 though? :P


_33(Posted 2007) [#7]
Actually, I tried that, and got an infinite loop :o


bytecode77(Posted 2007) [#8]
thats funny. half an hour ago, i discovered the php function crypt() which one-way-crypts a string.
maybee the word DES tells you something.

http://www.google.de/search?hl=de&q=des&btnG=Google-Suche&meta=

anyway, looking up to a table is dangerous and can certainly be hacked. the worst thing is to save the table as a plain text file anywhere in your project...


_33(Posted 2007) [#9]
Well, all I want to do is add a very simple live network protection scheme in the terminal system I'm building. I don't want to break barriers in inovation, just a simple live protection. This means that the key is generated at some point before the connexion occurs, and it is sent at some point. And from there, it can be used locally to decode incoming messages. So it means that both sides have a different key. Anyhow, this is all simplistic networking protection that I am thinking but I just want it to work and without any major flaw.


bytecode77(Posted 2007) [#10]
then you might just do a look-up table
you create an array with 256 entries and for every ascii-sign you define an other ascii-sign that will be converted into.


_33(Posted 2007) [#11]
Any code example for that? I have 4 :P And they are all posted in this here thread!


bytecode77(Posted 2007) [#12]
i'd suppose that you're better of writing it yourself, because you have your understanding in that. if you just copy it, you dont understand it and you can hardly change it;)