🔃 Sync Hub v0.4

This commit is contained in:
jokob-sk
2024-06-04 17:36:10 +10:00
parent 46e7e7bc01
commit 02eafadf15
7 changed files with 80 additions and 16 deletions

View File

@@ -13,6 +13,11 @@ import json
import time
from pathlib import Path
import requests
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import base64
import hashlib
import conf
from const import *
@@ -798,6 +803,13 @@ def collect_lang_strings(json, pref, stringSqlParams):
return stringSqlParams
def encrypt_data(data, key):
key = hashlib.sha256(key.encode()).digest() # Ensure the key is 32 bytes long
cipher = AES.new(key, AES.MODE_CBC) # Use CBC mode for encryption
iv = cipher.iv # Initialization vector
encrypted_data = cipher.encrypt(pad(data.encode(), AES.block_size))
return base64.b64encode(iv + encrypted_data).decode('utf-8')
#-------------------------------------------------------------------------------
# Misc
#-------------------------------------------------------------------------------