o
    _i}                     @   sR   d Z dededdfddZdeded	edefd
dZdeded	edefddZdS )z}Core mathematical operations.

This is the actual core RSA implementation, which is only defined
mathematically on integers.
varnamereturnNc                 C   s    t | trd S td|| jf )Nz%s should be an integer, not %s)
isinstanceint	TypeError	__class__)r   r    r   A/home/air/demo/back/venv/lib/python3.10/site-packages/rsa/core.py
assert_int   s   
r
   messageekeync                 C   sR   t | d t |d t |d | dk rtd| |kr#td| |f t| ||S )z@Encrypts a message using encryption key 'ekey', working modulo nr   r   r       z'Only non-negative numbers are supportedz#The message %i is too long for n=%i)r
   
ValueErrorOverflowErrorpow)r   r   r   r   r   r	   encrypt_int   s   


r   
cyphertextdkeyc                 C   s.   t | d t |d t |d t| ||}|S )zHDecrypts a cypher text using the decryption key 'dkey', working modulo nr   r   r   )r
   r   )r   r   r   r   r   r   r	   decrypt_int-   s
   


r   )__doc__r   strr
   r   r   r   r   r   r	   <module>   s   