title: Chrome 80 how to decode cookies
body: <p>I had a working script for opening and decrypting Google Chrome cookies which looked like:</p>
  
  <pre><code>decrypted = win32crypt.CryptUnprotectData(enctypted_cookie_value, None, None, None, 0)
  </code></pre>
  
  <p>It seems that after update 80 it is no longer a valid solution.</p>
  
  <p>According to this blog post <a href="https://blog.nirsoft.net/2020/02/19/tools-update-new-encryption-chrome-chromium-version-80/" rel="noreferrer">https://blog.nirsoft.net/2020/02/19/tools-update-new-encryption-chrome-chromium-version-80/</a> it seems that i need to CryptUnprotectData on encrypted_key from Local State file, than somehow decrypt cookie, using decrypted key.</p>
  
  <p>For the first part i got my encrypted_key </p>
  
  <pre><code>path = r'%LocalAppData%\Google\Chrome\User Data\Local State'
  path = os.path.expandvars(path)
  with open(path, 'r') as file:
      encrypted_key = json.loads(file.read())['os_crypt']['encrypted_key']
  encrypted_key = bytearray(encrypted_key, 'utf-8')
  </code></pre>
  
  <p>Then i tried to decrypt it </p>
  
  <p>decrypted_key = win32crypt.CryptUnprotectData(encrypted_key, None, None, None, 0)</p>
  
  <p>And got exception:</p>
  
  <pre><code>pywintypes.error: (13, 'CryptProtectData', 'The data is invalid.')
  </code></pre>
  
  <p>and i cant figure out how to fix it</p>
  
  <p>Also for the second part of encryption, it seems that i should use pycryptodome, something like this snippet:</p>
  
  <pre><code>cipher = AES.new(encrypted_key, AES.MODE_GCM, nonce=nonce)
  plaintext = cipher.decrypt(data)
  </code></pre>
  
  <p>But i can't figure out where i should get nonce value</p>
  
  <p>Can someone explain, how to do Chrome cookies decrypting correctly?</p>