| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/django/core/__pycache__/ |
Upload File : |
�
�|�e� � �X � d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl
mZmZ ddl
mZ ddlmZ ddlmZ ed � � Z G d
� de� � Z G d� d
e� � Zd� Zd� Zdd�Zdd�Z G d� d� � Zddedfd�Zddedfd�Z G d� d� � Z G d� de� � ZdS ) ae
Functions for creating and restoring url-safe signed JSON objects.
The format used looks like this:
>>> signing.dumps("hello")
'ImhlbGxvIg:1QaUZC:YIye-ze3TTx7gtSv422nZA4sgmk'
There are two components here, separated by a ':'. The first component is a
URLsafe base64 encoded JSON of the object passed to dumps(). The second
component is a base64 encoded hmac/SHA1 hash of "$first_component:$secret"
signing.loads(s) checks the signature and returns the deserialized object.
If the signature fails, a BadSignature exception is raised.
>>> signing.loads("ImhlbGxvIg:1QaUZC:YIye-ze3TTx7gtSv422nZA4sgmk")
'hello'
>>> signing.loads("ImhlbGxvIg:1QaUZC:YIye-ze3TTx7gtSv422nZA4sgmk-modified")
...
BadSignature: Signature failed: ImhlbGxvIg:1QaUZC:YIye-ze3TTx7gtSv422nZA4sgmk-modified
You can optionally compress the JSON prior to base64 encoding it to save
space, using the compress=True argument. This checks if compression actually
helps and only applies compression if the result is a shorter string:
>>> signing.dumps(list(range(1, 20)), compress=True)
'.eJwFwcERACAIwLCF-rCiILN47r-GyZVJsNgkxaFxoDgxcOHGxMKD_T7vhAml:1QaUaL:BA0thEZrp4FQVXIXuOvYJtLJSrQ'
The fact that the string is compressed is signalled by the prefixed '.' at the
start of the base64 JSON.
There are 65 url-safe characters: the 64 used by url-safe base64 and the ':'.
These functions make use of all of them.
� N)�settings)�baseconv)�constant_time_compare�salted_hmac)�force_bytes)�
import_string)�_lazy_re_compilez^[A-z0-9-_=]*$c � � e Zd ZdZdS )�BadSignaturezSignature does not match.N��__name__�
__module__�__qualname__�__doc__� � �5/usr/lib/python3/dist-packages/django/core/signing.pyr r 4 s � � � � � �#�#��Dr r c � � e Zd ZdZdS )�SignatureExpiredz3Signature timestamp is older than required max_age.Nr r r r r r 9 s � � � � � �=�=��Dr r c �P � t j | � � � d� � S )N� =)�base64�urlsafe_b64encode�strip)�ss r �
b64_encoder >