-2

I was wondering how I could program like a certain API, I have written an algorithm that I want to publish so people can use it, but I don't want people to see the code, and steal it? Paranoid, I know, but still.

How is that made, so for instance I can in a C# script (the API would also be written in C#), include it (with using ApiName) and use the functions inside, for instance if the API has a function that I program like "void Calculate(float x, float y)", and then from a script they can call "Calculate(100, 200)" for instance. I know it's somehow possible because of the Windows API, etc. Also is creating a Class Library the same thing?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Falconeer
  • 21
  • 4
  • You can't publish an algorithm without the source unless you're going to rewrite the algorithm in some other language... If someone has access to the code, and they really wanted to decompile it, they will. If you mean "provide an API", then you'd purchase a domain and a public web server first – OneCricketeer Sep 05 '21 at 17:18

1 Answers1

0

Before any code runs, it is either compiled or interpreted into binary. This is highly simplified but that is the general idea. As long as a library or API provides an interface like names of functions, the implementation itself can be compiled and still work.

For C#, NuGet is a good example, you can create a NuGet of your code (see https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package) where the public function and method signatures will be visible and usable but the implementations will be compiled. DLLs work in a similar way. You can reference them and call their public members but not see the code unless you use a tool to decompile them.

eglease
  • 2,445
  • 11
  • 18
  • 28
  • Okay thank you, yeah like somebody mentioned somebody will most likely decompile the API and look at the code, but I don't want it to be too easy to access it atleast xD Anyways thank you! – Falconeer Sep 05 '21 at 17:58
  • You can use a code obfuscation to prevent your code from being useful even if decompiled. There are lots of looks out there. https://stackoverflow.com/questions/59893/best-method-to-obfuscate-or-secure-net-assemblies – eglease Sep 05 '21 at 20:07