Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / DarkFish Encryption DLL

Author
Message
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jun 2007 15:58 Edited at: 26th Jun 2007 21:51
DarkFish Encryption DLL

I've started work on a DLL that will bring free strong encryption to the Dark Basic community. It's based on fast, strong, patent free algorithms.



Key generation 16-100ms (you do this only once)

Encrypt 2 DWORDS = 0ms/too fast to record!!

Decrypt 2 DWORDS = 0ms/too fast to record!!

Encrypt 44 Char String = 0ms/too fast to record!!

Decrypt 44 Char String = 0-15ms


It will be a FREE DLL!!

I'm going to use it to encrypt my game traffic so no-one can build a clone server for my client or a bot for my server. I'm sure the DBP community will find many uses for it as i often see people asking how to encrypt media.

Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 22nd Jun 2007 17:09
This is free? This could boost my server-to-client-to-server security with 90% ( i already handle like 80-90% of things with server)


[B] - LINKIN PARK - [/B]
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 22nd Jun 2007 17:20
GatorHex, a string becomes a dword when you return it because you are actually returning the memory address of the string, casted to dword (or unsigned int). For example:



That should work for a simple example, but keep in mind that you can't just create strings in your function and then return them. This is because they go out of scope once your function is left, so it is not guaranteed that the string reference will still be valid outside of your function. In order to handle strings properly with DBP, you have to mess with the globstruct, which i can't help you with.

Who needs a signature?
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 22nd Jun 2007 17:30
Quote: "GatorHex, a string becomes a dword when you return it because you are actually returning the memory address of the string, "

That is correct. If you return the DWord address of the string, it will work.


Come see the WIP!
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jun 2007 17:47
Cool, thanx for the help.

Yes it's going to be a total free DLL.

I hate it when people take free code, rebadge it then try to make money out of it. *cough* Unity LUA *cough*

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jun 2007 21:30 Edited at: 22nd Jun 2007 22:02
Quote: "That is correct. If you return the DWord address of the string, it will work."


ok but how, in DBP, do i turn a Dword address back into the string "hello"?

im trying this..

Ptr as DWORD
`Prt$ = DF_ReturnString() `This causes a cast error.
Ptr=DF_ReturnString() 'This just print the DWORD numbers
PRINT Ptr

everytime i try an print it i just get a dword number, waht am i doing wrong

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 22nd Jun 2007 22:12 Edited at: 22nd Jun 2007 22:15
Consider your string as an array of characters.

array[1]=h
array[2]=e
array[3]=l
array[3]=l
array[4]=o

To store a string in memory you have to assign each character an address.



http://3dfolio.com
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jun 2007 22:23 Edited at: 22nd Jun 2007 22:29
Yeah thats what i was thinking all you could do with a DWORD one character at a time, but Milkman and Cash have my hopes up that there is a way of grabbing the whole string. Maybe i missunderstood them?

Looks evil though, I'm wondering if I pass an array would faster

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 22nd Jun 2007 22:34
I don't understand what you mean by "grabbing the whole string".

You can't store a string of arbitrary length into a single memory address, if that's what you're trying to do. Unless you're storing a number you can only store one character per byte in memory. But in DBP's case it's one character per DWORD (4 bytes).

http://3dfolio.com
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jun 2007 22:50 Edited at: 22nd Jun 2007 23:14
how do C++ store a string? I was hoping it was like an array which is a memory pointer, because a string is realy array of char.

I thought the other two were saying store the string in a variable in the DLL and send back its memory location in a DWORD.

Milky was worried when leaving the function it might be lost but I'm pretty sure if I make a global it will live on as long as the DLL is loaded.

If I try and grab dword at a time I have no idea how long the string will be.

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 22nd Jun 2007 23:16 Edited at: 22nd Jun 2007 23:17
You could use IanM's util plugin.

From DLL 4:
Quote: "RESERVE$

Allocates a chunk of memory large enough to hold a string of the desired size, and returns its address.
Syntax

MemoryAddress = RESERVE$( StringSize )"


http://3dfolio.com
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Jun 2007 00:39 Edited at: 23rd Jun 2007 01:33
This is my effort at returning a string. If anyone knows where I'm going wrong dont be shy to say so


[main.cpp]
LPSTR str = "hello from the DLL";
DLLCMDC DWORD ReturnString(void)
{
StartFunction
return (DWORD)&str;
}


[commands.rc]
1 "DF_RETURNSTRING[%S%ReturnString"


[DBP]
Prt$ = DF_ReturnString()
print "top"
print Ptr$
print "bottom"


[Screen Result]
top
bottom

or

[main.cpp]
LPSTR str = "hello from the DLL";
DLLCMDC DWORD ReturnString(void)
{
StartFunction
return (DWORD)&str;
}


[commands.rc]
1 "DF_RETURNSTRING[%D%ReturnString"


[DBP]
Ptr as DWORD
Prt = DF_ReturnString()
print "top"
print Ptr
print "bottom"


[Screen Result]
top
12345678
bottom

Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 23rd Jun 2007 02:07 Edited at: 23rd Jun 2007 02:11
I made a mistake when i gave you my example earlier, that's why you've been having problems. You just cast the char pointer directly to dword and then return it, you don't cast the address of the char pointer to dword. My fault, sorry!

This should work (works for me):

main.cpp


stringtable.rc


DBP code


You're also right about the global variables. If you put your strings in global scope in your dll then your dbp program shouldn't have a problem using them, as the memory is never freed until the dll is.

Who needs a signature?
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Jun 2007 12:15
Thanks Milkman I'm returning strings now

However i got a new problem in my project compiling the command ultoa in Dev-C++.



results in..

ultoa undeclaired (first us this function)

Any ideas? I hope Dev-C++ is not ANSI only?

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Jun 2007 14:33 Edited at: 23rd Jun 2007 14:46
bah

sprintf(mystring, "%u", 4294967294);

is gona be a pain to work with

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jun 2007 21:34
So wrap it into a function and make it easier to work with!

BTW, did you see my update to your post in the DLL forum, regarding strings within a DBPro plug-in?

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Jun 2007 23:37
Yeah, thanx for the info. I realy have no choice but to get this DLL working so all help is greatfully recieved

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 24th Jun 2007 14:45 Edited at: 24th Jun 2007 15:13
Development has been put on hold for a week or so because I have to deliver a progress report on Monday and the week after an bound Interim report. I'd rather be coding than report writing but it's 10% of the final mark.

I would have liked to have delivered a DLL already but there seems to be some issues with Dev-C++ DBP DLL Framework. You can read here the issues http://forum.thegamecreators.com/?m=forum_view&t=97069&b=5&p=2. It could just be me of course not understanding what I'm doing, so feel free to say so if you want.

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 26th Jun 2007 02:54 Edited at: 26th Jun 2007 03:41
I gave up on the idea of passing string in and out of the DLL it was too much hassel. I'll write some functions to do it DBP instead for now.

Check out the new screenshot at the top of this page.

This baby is fast!

Key generation 100ms (you do this only once)

Encrypt 2 DWORDS = 0ms/too fast to record!!

Decrypt 2 DWORDS = 0ms/too fast to record!!

Considering i can pack one players movements into 1 DWORD it looks like it's not going to effect the speed of my game much!

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 26th Jun 2007 14:55 Edited at: 26th Jun 2007 17:47
I run into a major problem!

DBP val(dword) returns the wrong results!!!! OMG is this a bug or something stupid I've missed?

I cannot do encryption/decryption with inacurate numbers



[update]
Well i decided to convert everything to Hex to get around this.. i just hope i don't run into big/little endian issuse

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 26th Jun 2007 21:47
Ok everything working with hex you can now ecrypt strings, char pairs and DWORDS. I might write a text file encryption routine and a byte encryption before releasing it, mind you I should be getting on with my report writing

[check out the new screen shot at the top]

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 27th Jun 2007 20:37
ok it's ready to download now so I've moved it over to the program announcements thread

http://forum.thegamecreators.com/?m=forum_view&t=109067&b=5

Login to post a reply

Server time is: 2024-11-24 01:12:20
Your offset time is: 2024-11-24 01:12:20