https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
b

billowy-lizard-55653

11/29/2023, 4:33 PM
Hi all, I am using this approach (Vue2): https://docs.growthbook.io/lib/vue Does anyone know how to correctly pass in the decryptionKey? Supplying it to the growthBook instance doesn't seem to work, and I wonder if there is a way to pass it in when features are retrieved or set? In this method I've already retrieved the features in encrypted form, before the growthBook instance is created.
s

swift-helmet-3648

11/29/2023, 4:36 PM
Hi @limited-ghost-77841, the growthbook constructor in the JS SDK does accept a
decryptionKey
property
Sorry - I misread your comment. Strange that that isn't working. Our method
setEncryptedFeatures
accepts it as an argument as well.
b

billowy-lizard-55653

11/29/2023, 4:43 PM
Thanks Adnan, I can't see that method in the docs, what arguments does it take?
s

swift-helmet-3648

11/29/2023, 4:44 PM
Copy code
public async setEncryptedFeatures(
    encryptedString: string,
    decryptionKey?: string,
    subtle?: SubtleCrypto
  ): Promise<void>
b

billowy-lizard-55653

11/29/2023, 4:45 PM
Ok thank you that looks promising I will give that go
Is there any more documentation on this function? I have tried supplying the features as JSON as for setFeatures, and get the error "Failed to decrypt"
Copy code
const setFeaturePromise = new Promise(() => {
            growthBook.setEncryptedFeatures(json.features, decryptionKey)
          })
          await setFeaturePromise.then(() => {
            console.log(growthBook)
          })
Sorry the formatting is messed up there
s

swift-helmet-3648

11/29/2023, 5:25 PM
Is json.features an encrypted string?
Are you sure you've enabled encryption at the SDK connection level?
b

billowy-lizard-55653

11/29/2023, 5:53 PM
Thanks for your help, the issue was to use json.encryptedFeatures (clear from checking the endpoint), and this now works:
Copy code
await growthBook.setEncryptedFeatures(
            json.encryptedFeatures,
            decryptionKey
          )
I couldn't see this specific function in docs but it is useful to know about
8 Views