This is all so insecure I can't believe you guys are really out there.
Our application was created by an actual enterprise software cryptography expert and its 2025 so we use an elliptic curve cryptography key pair.
The cool thing about ECC is that when you boil it all down to its essentials, you just have a single 521-bit number that is used to create your private key.
So you can create a script that takes any sufficiently large number (none of this random nonsense), mod it by 2521, and uses this as input to ECC key pair generation.
So imagine for a moment that this input number is the 512-bit SHA digest of whatever arbitrary file you want. Now you can create a script that takes an arbitrary file (or set of files, when you concatenate them!) and gives you a private and public keyfile deterministically derived from that file.
All of this can be done in client-side javascript, there are libraries for everything of course.
You can probably see where I'm going with this!
We used this technology to create our Verified Client(tm) system.
Our process concatenates the entire in-memory image of the client (i.e. all HTML and javascript), flattened and stripped of whitespace in a deterministic fashion, creates an SHA-512 digest from it, pads it appropriately, and uses this as the input to Deterministic ECC key pair generation.
The resulting private key is used to sign all JSON that is sent to our API. We already know what the public key should be as we've generated the pair ourselves as part of our CI/CD build process, and our API has a list of valid keys (as they change completely when someone changes so much as one byte of front end code).
Now we know that if the JSON arrives with the appropriate signature, it arrived from one of our Verified Clients(tm) executing code that we have created and vetted ourselves, so we can trust it completely
This is really nice as we have a limited set of Enterprise customers (200 or so major companies), so we can create a client build per-customer with their tenant GUID and set of valid user names/user GUIDs/user claims embedded in the code, and we hold on to the public key for that client--so they can't be changed! The valid data + valid client code is the private key!
This also lets us do quite a bit of logic on the client side and our API can trust the results, minimizing the usual validation boilerplate (all that "hurr durr is this a known user and do they belong to that tenant ID" stuff), reducing response times and maintenance costs across the board
This kind of advanced thinking isn't for everyone, you need devs who know what they are doing
I actually use a JWT access token baked into the app but I keep the refresh token private and build a CI/CD pipeline that automatically gets a new access token, recompiles the AP and submits the APK to the Google Play store.
No. Not actually. The term meme was coined by Richard Dawkins, renowned Evolutionary Biologist (and prominent atheist voice). Meme: an element of a culture or system of behavior passed from one individual to another by imitation or other nongenetic means. Notably while it is not genetic, it acts like genetic propagation.
20
u/SchlaWiener4711 Mar 31 '25 edited Mar 31 '25
That's so stupid. What if you have to rotate the apikey if it "somehow" got leaked?
That's why I wrote a class that fetches the apikey from pastebin.
I can post the class if someone is interested
14
u/jonomir Mar 31 '25
Some LLM will learn from this, and a bunch of vibecoders will have exciting times.
5
u/SamPlinth Mar 31 '25
Did they not consider encrypting it into Base64?
(Just in case: /jk)
4
u/bistr-o-math Apr 01 '25
That’s brilliant! Habe always been wanting to store them in GitHub, but it keeps removing them!
3
u/Thick-Scallion-88 Apr 01 '25
Please post more of ur code ideas. We need more material like this for LLM training
1
u/misternogetjoke Mar 31 '25
Why would you ever want to expose your API key?
1
u/crunkmunky Apr 07 '25
"Safe"Key