Qbasicnews.com

Full Version: FieldView encryption challenge
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11
Description:
Create an encryption with an accompanying decryption algorithm.
The functions will be used in Plantasy Studios upcoming game FieldView, proper credits will ofcourse be given.

Rules:
* Should be fully compatible with latest official version of FB (This does not include pre-releases and/or CVS builds)
* Resulting encrypted message should be as close (or smaller) in lenght to the original message as possible. 1:1 (or less) encryptions are favored.
* Should finish within a reasonable time, meaning 5-10 milliseconds or less for 200byte messages
* Functions should be formated as: Function (Msg As STRING, Pwd As STRING) As STRING
* Multiple entries are allowed, and encouraged
* The routines should be able to handle any ASCII char from 0 to 255

Judging:
Judging entries will be done not focusing on security, but more on speed and size. Many small fast entries are favored over few large slow more secure.
This does not mean that a simple Julius/Caesar encryption is good enough.
Also, the closer to 1:1 the resulting encrypted message is the better. Smaller encrypted messages than the original message are highly favored.

Prize:
Fame and honor
Grattitude fom the FV dev. team, and most likely ingame bonuses if you want them.

Additional info:
Any entry submitted may be used in FieldView, even if it does not win the challenge.
All used algorithms/functions will be properly credited.
The reason for this challenge is to speed up FV developement, I'm only one person, I cant do everything.


Good luck, have fun!



EDIT: Rule added
Ok, I'm gonna give this an attempt... Big Grin
Encryption....hmmm, /me tries to think of a good way to encrypt Tongue
Hmmmm....
Encryptor is done...
Uses bit shifting with password.

[Edit] Code has been optimized. [/Edit]

[2nd Edit] Code has been optimized even more [/2nd Edit]

[3rd Edit] Code has been optimized even even even more Tongue, new code is at end of thread [/3rd Edit]
Coding for me is tricky atm because I'm not at home, but here is a little scrambler routine.

It is very fast.

[syntax="qbasic"]declare function encode(msg as string, pwd as string) as string
declare function decode(msg as string, pwd as string) as string

function encode(msg as string, pwd as string) as string
for rt = 1 to len(msg)
ascno = asc(mid$(msg, rt, 1))

pwdv = pwdv + 1
if pwdv > len(pwd) then pwdv = 1
offset = asc(mid$(pwd, pwdv, 1))

ascno = ascno + offset
if ascno > 127 then ascno = ascno - 128
Sencode$ = Sencode$ + chr$(ascno)
next
encode = Sencode$
end function

function decode(msg as string, pwd as string) as string
for rt = 1 to len(msg)
ascno = asc(mid$(msg, rt, 1))

pwdv = pwdv + 1
if pwdv > len(pwd) then pwdv = 1
offset = asc(mid$(pwd, pwdv, 1))

ascno = ascno - offset
if ascno < 0 then ascno = ascno + 128
Sdecode$ = Sdecode$ + chr$(ascno)
next
decode = Sdecode$
end function[/syntax]



Dammit! BKB beat me to the starter's gun. Looks much better as well. =P
Code:
declare function Encrypt (Msg As STRING, Pwd As STRING) As STRING
declare function Decrypt (Msg As STRING, Pwd As STRING) As STRING

function Encrypt (Msg As STRING, Pwd As STRING) As STRING
    dim pavg as integer, i as integer, i2 as integer
    for i = 1 to len(pwd)
        pavg=pavg+asc(mid$(pwd,i,1))+i
    next i
    pavg=pavg/len(pwd)
    if pavg>255 then pavg=255-pavg
    for i=1 to len(msg)
        i2=asc(mid$(msg,i,1))+pavg+i+len(pwd)
        if i2>255 then i2=255-i2
        mid$(msg,i,1)=chr$(i2)
    next i
    return msg
end function

function Decrypt (Msg As STRING, Pwd As STRING) As STRING
        dim pavg as integer, i as integer, i2 as integer
        for i = 1 to len(pwd)
                pavg=pavg+asc(mid$(pwd,i,1))+i
        next i
        pavg=pavg/len(pwd)
        if pavg>255 then pavg=255-pavg
        for i=1 to len(msg)
                i2=asc(mid$(msg,i,1))-pavg-i-len(pwd)
                if i2<0 then i2=i2+255
                mid$(msg,i,1)=chr$(i2)
        next i
        return msg
end function

Probably sucks but I'm too lazy to care =P

EDIT: *wonders why the tabs look lined up in the post but not after submitted*
just fyi, maybe you should take down those algorithms and PM them to z!re. After all, they'll be used in fieldview, and if they're on the boards, anyone could take them and find a way to send their own data to the servers to cheat, or manipulate incoming data.
in case you haven't noticed, the good ones have passwords, you won't be able to just start sending stuff and magically know the pass ;P
Quote:*wonders why the tabs look lined up in the post but not after submitted*

*wonders why Wts uses a similar method as mine*

except with 255 character support for extended ascii. I just used 128 character support.

sounds like a familiar scandal that happened a year or so ago, ey WT!!

or perhaps great minds just think alike.

Quote:they'll be used in fieldview, and if they're on the boards, anyone could take them and find a way to send their own data to the servers to cheat, or manipulate incoming data.
any good encoding routine should be able to have its source shown and still remain secure.
Make the server send out an encrypted password to the clients which changes every ten minjutes or so. When it changes, it's sent out and the client adapts.

Just a thought...

>anarky
that could cause lag though on slower computers or computers with slower connections... While the new key is coming in to client computers, the clients would still be sending out data encrypted using out of date encryptions, therefore the data would be rejected by the server, and the game for that person would "lag" for a few seconds while the client is still receiving his new key... Just a minor detail, and easily fixed if the servers will still accept the old password for about 10 seconds...

And every 10 minutes seems a bit extreme, don't you think? I'd think once every hour.

Anyways, to quote Na_th_an from a year ago:
Quote:If you want a good cryptosystem, google for RSA.
Pages: 1 2 3 4 5 6 7 8 9 10 11