• Documentation
  • /
  • Remix Supabase
  • /
  • Encrypting Secrets

Encrypting Secrets

When storing sensitive data, such as API keys, you must ensure to encrypt your data in Firestore. Here is how we can encrypt and decrypt it.

When storing sensitive data, such as API keys, you must ensure to encrypt your data in Database.

To use these utilities, you must provide an environment variable named SECRET_KEY. This should be provided safely using your CI since it's a secret key.

MakerKit provides some utilities to encrypt and decrypt your data.

import { encrypt, decrypt } from '~/core/generic/crypto';

// storing secrets
function storeApiKey(key: string) {
  const encryptedKey = encrypt(key);

  return storeKeyInFirestore(encryptedKey);
}

// retrieving secrets
function getApiKey(id: string) {
  const encryptedKey = await getApiKeyFromFirestore(id);

  return decrypt(encryptedKey);
}

Stay informed with our latest resources for building a SaaS

Subscribe to our newsletter to receive updatesor