Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3.8 AttributeError: module 'time' has no attribute 'clock' #27

Open
tnusraddinov opened this issue May 17, 2020 · 6 comments · May be fixed by #26
Open

Python3.8 AttributeError: module 'time' has no attribute 'clock' #27

tnusraddinov opened this issue May 17, 2020 · 6 comments · May be fixed by #26

Comments

@tnusraddinov
Copy link

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/simplecrypt/__init__.py", line 42, in encrypt salt = bytes(_random_bytes(SALT_LEN[LATEST]//8)) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/simplecrypt/__init__.py", line 137, in _random_bytes return _hide(bytearray(getrandbits(8) for _ in range(n))) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/simplecrypt/__init__.py", line 137, in <genexpr> return _hide(bytearray(getrandbits(8) for _ in range(n))) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/Crypto/Random/random.py", line 51, in getrandbits return mask & bytes_to_long(self._randfunc(ceil_div(k, 8))) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 202, in read return self._singleton.read(bytes) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 178, in read return _UserFriendlyRNG.read(self, bytes) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 129, in read self._ec.collect() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 77, in collect t = time.clock() AttributeError: module 'time' has no attribute 'clock'

@DykemaBill
Copy link

Looks like this project is maybe dead? I am seeing the same problem.

@0xBeacon
Copy link

Same here. Python 3.8.5

@DykemaBill
Copy link

I ended-up writing my own using Fernet, you can find it here, works as a library or from command line:

https://github.com/DykemaBill/redirector/blob/master/redirectorencryptpass.py

@arunanshub
Copy link

arunanshub commented Aug 11, 2020

I ended-up writing my own using Fernet, you can find it here, works as a library or from command line:

https://github.com/DykemaBill/redirector/blob/master/redirectorencryptpass.py

Hello @DykemaBill @thatchriseckert, you might consider using pyflocker as it provides better support for ciphers, both symmetric and asymmetric, along with Hashes. It offers a seamless interface to Pycryptodome(x) and pyca/cryptography, by using them as cryptographic backends. It also provides a file encryption tool. Also, the AES modes that do NOT support HMAC can optionally be made to use HMAC internally. Other than that, it also provides Camellia cipher with HMAC support.

All the symmetric ciphers support writing into file and file-like objects, which means, you don't have to write a separate function to perform a file or file-buffer encryption/decryption. Hopefully, this saves a lot of time for the developer.

This module also brings enhancements and additions by improving AES-EAX support for pyca/cryptography, which is NOT present natively. Also, ChaCha20-Poly1305 has been implemented for pyca/cryptography to be compatible with PyCryptodome(x).

@ponchety
Copy link

ponchety commented Jan 6, 2021

Hi evryone!
I have the problem I guess, when I'm trying to .exe the script to encrypt a file in a Lab from GNS3 with an Ubuanto Automated Machine, doesn't work.

root@NetworkAutomation-1:~# python3 encrypt_device_info.py

Input CSV filename (device-creds) :
Encryption key (cisco) :

----- device_creds ---------------------------------------------------
[['192.168.122.71', 'david', 'cisco'],
['192.168.122.72', 'david', 'cisco'],
['192.168.122.73', 'david', 'cisco'],
['192.168.122.74', 'david', 'cisco'],
['192.168.122.75', 'david', 'cisco']]

Output encrypted filename (encrypted-device-creds):
Traceback (most recent call last):
File "encrypt_device_info.py", line 24, in
dc_out.write( encrypt( key, json.dumps( device_creds_list ) ) )
File "/usr/local/lib/python3.8/dist-packages/simplecrypt/init.py", line 42, in encrypt
salt = bytes(_random_bytes(SALT_LEN[LATEST]//8))
File "/usr/local/lib/python3.8/dist-packages/simplecrypt/init.py", line 137, in _random_bytes
return _hide(bytearray(getrandbits(8) for _ in range(n)))
File "/usr/local/lib/python3.8/dist-packages/simplecrypt/init.py", line 137, in
return _hide(bytearray(getrandbits(8) for _ in range(n)))
File "/usr/local/lib/python3.8/dist-packages/Crypto/Random/random.py", line 51, in getrandbits
return mask & bytes_to_long(self._randfunc(ceil_div(k, 8)))
File "/usr/local/lib/python3.8/dist-packages/Crypto/Random/_UserFriendlyRNG.py", line 202, in read
return self._singleton.read(bytes)
File "/usr/local/lib/python3.8/dist-packages/Crypto/Random/_UserFriendlyRNG.py", line 178, in read
return _UserFriendlyRNG.read(self, bytes)
File "/usr/local/lib/python3.8/dist-packages/Crypto/Random/_UserFriendlyRNG.py", line 129, in read
self._ec.collect()
File "/usr/local/lib/python3.8/dist-packages/Crypto/Random/_UserFriendlyRNG.py", line 77, in collect
t = time.clock()
AttributeError: module 'time' has no attribute 'clock'
root@NetworkAutomation-1:~#

The is any advice on how to fix it? I guess there is a library issue, but not sure

@ponchety
Copy link

ponchety commented Jan 6, 2021

Ok, Already fixed!
venv/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py line 77 to t = time.time() and it is now fixed.
Have been Googling and seems like t = time.clock() is deprecated

@KyleKing KyleKing linked a pull request Feb 12, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants