If I turn on encrypted SDK endpoints, is there a g...
# announcements
c
If I turn on encrypted SDK endpoints, is there a guide on how I use the features with both javascript and c#?
f
For javascript, you just need to pass in a decryptionKey when instantiating your GrowthBook instance:
Copy code
const gb = new GrowthBook({
  apiHost: "<https://cdn.growthbook.io>",
  clientKey: "sdk-abc123",
  decryptionKey: "key_abc123",
});
For C#, we don't yet have built-in support for decryption in the SDK
We have some docs on how the decryption algorithm works if you want to try implementing it yourself in C#. If you have access to openssl, it's fairly straight forward. https://docs.growthbook.io/lib/build-your-own#decryptencryptedstring-string-decryptionkey-string-string
c
from the SDK I can get both the encrypted and decrypted feature flags?
my plan is to get the flags and store it in my db myself
its not a huge deal for me to have the plaintext on the backend in c#
its teh frontend that I want the encryption
and for various reasons, I want to feed it the flag definition rather than have it load on pageload
f
Ok. There's no easy way to get both encrypted and plain text features from the same API endpoint. You can create multiple SDK Connections in GrowthBook, one with encryption enabled and one without. That will give you two different feature endpoints to fetch from. For javascript, you can use the
setEncryptedFeatures
method if you don't want to fetch from the front-end.
c
where can i see help for setencryptedfeatures?
b
async setEncryptedFeatures(_encryptedString_*:*
_string_, _decryptionKey_*?:*
_string_, _subtle_*?:* SubtleCrypto)*:* Promise<_void_>
is a method on the GrowthBook instance. there's no documentation around it (i've added an issue for us to address this), it seems but it's similar to
setFeatures(json)
except you'd pass it the encrypted response string (e.g. the result of
encryptedFeatures
in this example) with a decryption key. if on node, you'll need to pass in the polyfill for subtcrypto too (docs) otherwise the browser's webcrypto should be fine.