Like Tree3Likes

Encrypting reusable code

This is a discussion on Encrypting reusable code within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, i'm new here but i've already gotten a lot of help reading these forums. Now I have a ...

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    6

    Lightbulb Encrypting reusable code

    Hello everyone, i'm new here but i've already gotten a lot of help reading these forums.

    Now I have a question that was not answered by google.

    I want to write a DirectX11 based game-engine (i'll probably give up and fail, but i want to give it a try). Now, if i ever wanted to put that engine online for free use, i would write my own API that you could use.

    Now i don't want that everyone can just read my source code i wrote, because of all my hard work, so, is there a possibility that you can hide/encrypt your code, but that it is still usable?

    That means that they cannot SEE my sourcecode, but still use the API i wrote?

    Thanks in advance

    (sorry for the bad english)

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,621
    Compile a library (dll). Beware that this does absolutely not work with templates, one of C++'s most wonderful and powerful features. Also beware of the ABI. Typically only the same compiler that was used to compile the libraries can be used when linking against them.
    Another way is to encrypt the source files and provide a compiler that can decrypt them on-the-fly when compiling it (but obviously not saving the decrypted copies anywhere). Note that it isn't fool proof since the key must be somewhere and the source will be decrypted in memory as the compiler parses it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    May 2013
    Posts
    6
    Quote Originally Posted by Elysia View Post
    Compile a library (dll). Beware that this does absolutely not work with templates, one of C++'s most wonderful and powerful features. Also beware of the ABI. Typically only the same compiler that was used to compile the libraries can be used when linking against them.
    Another way is to encrypt the source files and provide a compiler that can decrypt them on-the-fly when compiling it (but obviously not saving the decrypted copies anywhere). Note that it isn't fool proof since the key must be somewhere and the source will be decrypted in memory as the compiler parses it.
    Thanks for the answer, but aren't dll's decompileable? I'm not shure.

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,261
    Beware that this does absolutely not work with templates, one of C++'s most wonderful and powerful features.
    O_o

    You can't have a template in a shared library, but you can have the expansion of a template in a shared library.

    Also beware of the ABI.
    Indeed.

    The recommended strategy for C++ is just to provide the code with an appropriate licensing model.

    Thanks for the answer, but aren't dll's decompileable?
    I thought you wanted to protect your code!?

    No. You can't protect your binary. Ever.

    If I want to see what you've done bad enough, I will look, and I'm not even very good at that sort of thing.

    You shouldn't try to do that in the first place. If you make a great engine, people who might use it will use it because it is great. The majority of people will not steal your work because it is simply not worth the effort.

    Soma
    Last edited by phantomotap; 05-09-2013 at 10:12 AM.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,621
    Quote Originally Posted by joejoepie View Post
    Thanks for the answer, but aren't dll's decompileable? I'm not shure.
    Nothing is perfect. You are just going to have to live with the fact that if someone is determined enough, they CAN and WILL get the source.
    You get use all kinds of draconian models to keep them from getting the source, but then you are just going to make it a bigger headache for those who just want to use your API without being interested in the source.
    So find a middle ground. It's better to make your customers happy than to use draconian measures to protect your source.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    May 2013
    Posts
    6
    Thanks. Yes i want to protect my code, but not like to way Unreal Engine does it.
    The reason why you'll never find Unreal Engine c++ source code online is because of the giant license costs, i can't do that kind of thing.
    If you ask €200 for a license, nothing will stop them from uploading it on the internet.

    So, is there just a way to obfuscate the code, so it's at least not 'easily' visible?

    Thanks again for your great replies so far

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,621
    Quote Originally Posted by joejoepie View Post
    So, is there just a way to obfuscate the code, so it's at least not 'easily' visible?
    You've been given two options.
    Actually, compiling code kind of "obfuscates" it. You can decompile it, but it won't be easily readable.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,261
    The reason why you'll never find Unreal Engine c++ source code online is because of the giant license costs, i can't do that kind of thing.
    *typety-type*

    *searchety-search*

    *clickity-click*

    O_o

    Wow. I found the source code for "Unreal Engine 3"!

    |\\|0\\|/ ! (4|\\| 5+341 +|-|3 (0|)3 1!|(3 +|-|3 31!+3 |\\/|0+|-|3|2 |#|_|(|(3|2 ! 4|\\/|!

    o_O

    Seriously now, the reason you don't really see people using the "Unreal Engine" without a license has nothing to do with the availability of the code. The "UDK" is available with a license that allows newbie or independent developers access to the engine and fixtures; now granted, the "UDK" doesn't have all the source, but the developers using the "UDK do not need it. The people who license the engine itself, the ones who get the source, don't care nearly as much about the code as you seem to think; the people who license the engine are basically licensing expertise. The source is fantastic, but engine source is just a small part of a game. Calling on the expertise offered by Epic is virtually priceless.

    If you ask €200 for a license, nothing will stop them from uploading it on the internet.
    Well, because you are shooting for a bizarre hypothetical, I feel a little reality needs to be injected.

    You will never build a game engine sophisticated enough to warrant a €200 license that doesn't come with the source code without considerable value coming from other components of the license.

    I don't intend any offense, but that's the reality. If I don't get the source code so that I may modify the engine to suite my purposes, I can use any of the hundreds of "GDK" available, but you aren't going to compete with those because many of them have more value because they often have content packs or support tickets. The offering of a $180 per seat (USD) "GDK" which grants me licensing rights to use several dozens of textures, models, and animation libraries in any number of products I wish to create takes your game engine out of my considerations. A different "GDK", from a different vendor, has four support claims per seat at $150 per seat with content packs offered on a per game basis for any individual or group with at least one seat; they will literally walk you through using any part of the "GDK" over the telephone or email; that's a value you can't possibly match by yourself.

    That's to say nothing of percentage licensing models from "GDK" vendors. You would pay no cost per game, asset, or developer; you only pay a small few per unit sold. For a new developer with little capital or an unsteady idea this sort of licensing model blows an initial license fee out of the water.

    Beyond that, we also have engines and "GDK" available under an open source model which would still allow the game to be a commercial, closed source project. Many such engines and "GDK" exist, and many of those have rather large and dedicated fans who work to support others. You aren't going to compete with that unless your expertise in game engines is extraordinary.

    There are a lot of developers out there who want to be the "Super King" of a new game engine. (I am one of them.) Beyond these issues, you also have the simple fact that you are not going to make a strong general purpose game engine out of the gate. You will need a lot of practice, and you'll need several iterations of engine design to have something worth even knowing about. I am not, in any way, trying to discourage you. I have tried and failed to write a great general purpose game engine many times. These problems have nothing to do with you. You have a lot going against you, and you are adding to your problems by trying to protect your work. You work is going to be that valuable for a long time. You need to focus on getting the work done, and if you are going to sell your work, you need to focus on work that will provide a great value because you have a lot of competition. You get that done and the source code will not be the selling point that drives sales.

    Soma

  9. #9
    Registered User
    Join Date
    May 2013
    Posts
    6
    I'm not saying i will ever complete my engine, and it's actually just a test for myself.
    I want to see what i'm capable of, and if i would ever complete the engine, it would most probobly be free.
    And then, let's say, like ten bucks for the source xp
    I'm 16 years old, but programming has been my passion for 4 years already. In my dreams i will be a great engine/game maker
    but i know that the possibility is quite small, though i will do everything i can to enlighten myself in the arts of c++/java and 2D/3D game programming
    Please don't think that i'm a stuckup guy who claims to be the best programmer, I just program as a hobby, at this moment. I do wish to make it my profession later.

    Thanks for your nice and fast reactions, it serieusly helped me out!

    Greets
    Wouter

  10. #10
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,261
    i know that the possibility is quite small
    O_o

    No. The possibility is only small if you go into things with the wrong mindset.

    If you are willing to work at, to try and fail many times, the possibility of you being a great programming, making great games, and a great game engine is, in fact, very high.

    The problem with so many newbies isn't the target; they can't make the journey.

    [Edit]
    That said, if you are willing to offer a license to use the engine for free with the source available for a fee, why not go the "donationware" route?

    You can give people who donate a username/password for source control so they can follow developments with everyone else on API release cycle.

    Maybe it is just me, but I feel that approach sends a better message.
    [/Edit]

    Soma
    Last edited by phantomotap; 05-09-2013 at 12:23 PM.
    iMalc and laserlight like this.

  11. #11
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by joejoepie View Post
    I'm not saying i will ever complete my engine, and it's actually just a test for myself.
    I want to see what i'm capable of, and if i would ever complete the engine, it would most probobly be free.
    And then, let's say, like ten bucks for the source xp
    I'm 16 years old, but programming has been my passion for 4 years already. In my dreams i will be a great engine/game maker
    but i know that the possibility is quite small, though i will do everything i can to enlighten myself in the arts of c++/java and 2D/3D game programming
    Please don't think that i'm a stuckup guy who claims to be the best programmer, I just program as a hobby, at this moment. I do wish to make it my profession later.

    Thanks for your nice and fast reactions, it serieusly helped me out!

    Greets
    Wouter
    You're not ready to write a game engine. You WILL fail. Writing a fully-fledged DX11 game engine is an enormous task, which requires enormous dedication. Judging from your posts your determination is missing, which means you won't complete. Forget about this project and pick a less challenging one that you are more confident about, return to this project once you feel confident about your capabilities.

    The hardest things about writing large amounts of code for hobby-purposes in my experience is:
    1. resisting the urge to start over when the code isn't as flawless as you would like (a naiive expectation for any large project)
    2. not losing interest in the project.

    Both of these require determination and willpower, if you're not confident before starting, you won't finish.

    Also, how many game engines have you used? How many games have you made? Writing a game engine isn't the first project you should throw yourself at.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  12. #12
    Registered User
    Join Date
    May 2013
    Posts
    6
    Thanks phantomotap, and yes, that would be a better approach

    For Neo1, i started programming when i was twelve, i've fully mastered Unity, i've used UDK and i've used CryEngine.
    I have studied Java, C#, C++ and C. And i'm not saying that this means that i can do this, but it also doesn't mean that i WILL fail, like you so gently say.

    This DirectX thing is a preperation for the college i want to go to. It's a school dedicated to making games, and the content of it.
    I've heard and seen that the school is very hard, so i'm preparing myself. The reason why i choose making a game engine, is because i need an objective.
    Taking a hard objective means that i will have a very hard time, and that i will have to do a lot of research, which means that i will learn a lot, and THAT'S my actual goal.

    It's nice that you want to help people on these forums, but you should not "kill" the dreams of new programmers. I've already written a small 2D game engine in java, so i'm taking the step to 3D.

    Greets

  13. #13
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by joejoepie View Post
    This DirectX thing is a preperation for the college i want to go to. It's a school dedicated to making games, and the content of it.
    I've heard and seen that the school is very hard, so i'm preparing myself.
    Try to gain some sound theoretical knowledge on Computer Graphics first.
    You will be much more prepared than blindly trying to make an 'engine'.
    The reason why i choose making a game engine, is because i need an objective.
    Taking a hard objective means that i will have a very hard time, and that i will have to do a lot of research, which means that i will learn a lot, and THAT'S my actual goal.
    It's nice that you want to help people on these forums, but you should not "kill" the dreams of new programmers.
    Read this article very carefully:
    http://scientificninja.com/blog/write-games-not-engines
    I've already written a small 2D game engine in java, so i'm taking the step to 3D.
    Please don't take it otherwise, but by thinking about 'protecting' your code before starting to write it, you are misguiding yourself.
    Cat likes this.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  14. #14
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Quote Originally Posted by joejoepie View Post
    Taking a hard objective means that i will have a very hard time, and that i will have to do a lot of research, which means that i will learn a lot, and THAT'S my actual goal.

    It's nice that you want to help people on these forums, but you should not "kill" the dreams of new programmers. I've already written a small 2D game engine in java, so i'm taking the step to 3D.
    Well, there's a difference between picking something hard yet realistic and picking something impossible for your skill level. The best projects to learn and grow from aren't just picking the most challenging thing you can think of. The best projects are those that are a small to medium amount above your current skill level. Sure, you can have a long-term goal in the back of your mind to work towards, but your actual effort should be expended at projects that are closer to your skill level. You'll learn a lot more, and you'll learn the RIGHT things. It's like training for anything - if you ever learned to ski, dd you start your first lessons on triple black diamond slopes? Certainly not. You need to keep challenging yourself, but the best challenges are those that are just a bit out of your current reach.

    With a project well above your skill level, you miss the mark in so many ways and by so much you don't really learn much. What you want is to stumble, but to be close enough that you can learn from your stumblings.

    Also, nobody here wants to kill dreams, but help you temper your dreams with reality. I can't count how many people I've seen that pick a project far beyond their current level, try for a while, fail, and quit programming. Could they have reached their ambitious goals? Most of them probably could have, had they understood that becoming an expert programmer takes a long, long time. The "10,000 hours" rule is a good estimate for developing expertise in many areas, and by that rule, if you work 40 hours per week, you need to work for about five years to become great at something. If you have lofty goals, you need to come to an understanding that you need to work harder and longer than you imagined.

    The shortest distance towards your goal is also not going to be the direct route - even if your long-term goal is a game engine, you actually will get there faster by working on other things first, to build the skills to tackle the difficult project.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  15. #15
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,261
    Read this article very carefully:
    That article is trash: "No matter what your reasons are — it doesn’t matter if you’re writing an engine so you can write your dream game, or if you’re writing an engine because you think it will be a good learning experience, or any number of similar reasons. They’re all wastes of time." and "If you repeat this process long enough, after a few games you’ll have the beginnings of a solid collection of reusable functionality that has been proven to have practical applications. You’ll also have a set of far more interesting demonstration applications that could also double as test harnesses for your engine.".

    Talk about broken logic; if trying and failing is valuable in that one can learn from the experience, the learning experience is always valuable.

    The biggest problem I have with the article is the payoff: "This method of growing an engine is superior because it helps you shape your goals, it forces you to actually think about the problems you will face and their practical implementations, it forces you to think about the separation between the domain-specific logic of the engine and the game."

    Actually, no, such a process does not force you to consider the separation of mechanism and abstraction, of implementation and design; it fails to hit such a useful goal for a simple reason: if you don't concern yourself with such considerations from the very start you can not possibly generalize and abstract what you learn during the development process of the games you build; you will ultimately and only be trying to reuse code; those two things aren't even in the same universe.

    You must force yourself to consider the separation of ideas, of components, of game versus engine for the iterative refinement to succeed in any way. Those considerations are not the end result of learning about development; they are the foundation!

    If you force yourself to plan, to think over the engine during the development of a game, then, and only then, do you learn about engine development by building games. People can say "To begin with, the term “engine” has no strict definition." all they like, and I will not argue, but for the iterative refinement of a game engine through game development to work at all the engine must be part of the development process regardless of your definition of "engine". Call it a "stealth engine", "API", or just "class library" if you like, call it whatever you wish, but to learn the shape of such things, such things must already be among the things with which you have concerned yourself.

    If you do not force yourself to focus, for example, on the separation of camera logic from how any given game may use a camera you can not possibly build general purpose camera system for your engine. You can't refine a camera system from a game for use in an engine unless the notion of having a camera system is already part of the design. If you've thrown camera controlling code all over the place, such that the code is difficult, you only learn that you need a camera system, but to actually refine a camera system, one must exist. You can call the system whatever you like, to be part of whatever you like, but to learn from the implementation, you have to intentionally be building such a system.

    Soma

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encrypting with User-Given Key
    By BrieRose in forum C++ Programming
    Replies: 3
    Last Post: 05-04-2013, 09:29 AM
  2. Encrypting passwords
    By FlyingIsFun1217 in forum C++ Programming
    Replies: 23
    Last Post: 12-01-2006, 01:48 AM
  3. help with encrypting plz
    By wimpman in forum C Programming
    Replies: 9
    Last Post: 03-31-2004, 02:29 PM
  4. Function not reusable?
    By mart_man00 in forum C Programming
    Replies: 3
    Last Post: 09-07-2003, 09:02 PM
  5. Encrypting still
    By bitWise in forum C Programming
    Replies: 1
    Last Post: 10-15-2001, 07:26 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21