o
    }j6h}  ã                   @   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   úW/var/www/html/chefvision.cloud.itp360.com/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   