← Back
Editing: Windows.cpython-311.pyc
� <&c] � �� � d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm Z ddl mZ d dlZn# e $ r Y nw xY w ddl mZ n# e $ r Y nw xY wd� Z G d � d ej � � Z G d� de� � ZdS ) � N)� properties)�KeyringBackend)�PasswordDeleteError�ExceptionRaisedContext� )� file_base)�_win_cryptoc � � t � � 5 } t j ddd� � n# 1 swxY w Y t | � � S )z� Does this environment have wincrypto? Should return False even when Mercurial's Demand Import allowed import of _win_crypto, so accesses an attribute of the module. N)r r �__name__�bool)�excs �6/usr/lib/python3/dist-packages/keyrings/alt/Windows.py� has_wincryptor sy � � � !� !� �S����� � � � � � � � � � ���� � � � ��C�y�y�=�s � (�,�,c �J � e Zd ZdZdZej d� � � ZdZdd�Z dd�Z dS ) �EncryptedKeyringz= A File-based keyring secured by Windows Crypto API. z1.0c �R � t j � � dk st d� � �dS )zr Preferred over file.EncryptedKeyring but not other, more sophisticated Windows backends. �Windows�Requires Windowsg�������?)�platform�system�RuntimeError��selfs r �priorityzEncryptedKeyring.priority( s+ � � �� � �I�-�-��1�2�2�2��s� zwincrypto_pass.cfgNc �* � t j |� � S )z(Encrypt the password using the CryptAPI.)r �encrypt)r �password�assocs r r zEncryptedKeyring.encrypt4 s � ��"�8�,�,�,r c �* � t j |� � S )z(Decrypt the password using the CryptAPI.)r �decrypt)r �password_encryptedr s r r! zEncryptedKeyring.decrypt8 s � ��"�#5�6�6�6r )N)r � __module__�__qualname__�__doc__�versionr � classpropertyr �filenamer r! � r r r r ! sq � � � � � �� � �G���� � ��� $�H�-� -� -� -�7� 7� 7� 7� 7� 7r r c �` � e Zd ZdZej d� � � Zed� � � Zd� Z d� Z d� Zd� ZdS ) �RegistryKeyringz� RegistryKeyring is a keyring which use Windows CryptAPI to encrypt the user's passwords and store them under registry keys c � � t j � � dk rt d� � �t � � st d� � �dS )zC Preferred on Windows when pywin32 isn't installed r r zRequires ctypes� )r r r r r s r r zRegistryKeyring.priorityC sF � � �?��� �)�)��1�2�2�2���� 2��0�1�1�1��qr c �` � | � dd� � } dj di t � � ��S )N�\�__0x5c__zSoftware\{escaped}\Keyringr) )�replace�format�locals)�service�escapeds r �_key_for_servicez RegistryKeyring._key_for_serviceN s3 � ��/�/�$� �3�3��3�,�3�?�?�f�h�h�?�?�?r c �l � | � |� � }t j t j |� � }t j ||� � d }|� d� � }t j |� � }t j |� � � d� � }n# t $ r d}Y nw xY w|S )z,Get password of the username for the servicer �ascii�utf-8N)r6 �winreg�OpenKey�HKEY_CURRENT_USER�QueryValueEx�encode�base64�decodebytesr r! �decode�EnvironmentError) r r4 �username�key�hkey�password_saved�password_base64r"