diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b65e5263..06deb0f65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: PLAIN_OUTPUT: True REDIS_URL: "localhost:6379" IS_TESTING: True - ENCRYPTION_KEY: "dummy key" + ENCRYPTION_KEY: "abcdefghijklmnopqrstuvwxyz123456" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 diff --git a/config_template.yaml b/config_template.yaml index c5e83df19..9309a588f 100644 --- a/config_template.yaml +++ b/config_template.yaml @@ -55,8 +55,8 @@ GITHUB_CLIENT_ID: GITHUB_CLIENT_SECRET: FRONTEND_URL: "http://localhost:3000" -#ENCRPYTION KEY -ENCRYPTION_KEY: secret +#ENCRPYTION KEY, Replace this with your own key for production +ENCRYPTION_KEY: abcdefghijklmnopqrstuvwxyz123456 #WEAVIATE diff --git a/superagi/helper/encyption_helper.py b/superagi/helper/encyption_helper.py index 4939b1d0c..ec49e3d39 100644 --- a/superagi/helper/encyption_helper.py +++ b/superagi/helper/encyption_helper.py @@ -1,3 +1,5 @@ +import base64 + from cryptography.fernet import Fernet, InvalidToken, InvalidSignature from superagi.config.config import get_config # Generate a key @@ -6,9 +8,19 @@ key = get_config("ENCRYPTION_KEY") if key is None: raise Exception("Encryption key not found in config file.") + +if len(key) != 32: + raise ValueError("Encryption key must be 32 bytes long.") + +# Encode the key to UTF-8 key = key.encode( "utf-8" ) + +# base64 encode the key +key = base64.urlsafe_b64encode(key) + +# Create a cipher suite cipher_suite = Fernet(key)