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

Fix encryption for Python <= 3.7 #93

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kroq-gar78
Copy link

@kroq-gar78 kroq-gar78 commented Sep 30, 2024

While working on #91 I was unable to upload or download anything with an encrypted interface. This code should at least allow the test code below to run.

Given encryption has been broken I'm not sure if anyone has actually used it recently. This might break compatibility with existing encrypted objects, so I would appreciate if someone could test if you could read existing objects.

Note that these changes are only for Python <= 3.7, since PyCrypto depends on time.clock , which was removed in Python 3.8. Both this PR and #91 are necessary for supporting >= 3.8.

Test code

I also did not see any automated tests for this, so here's a short snippet that should work:

import os; import cottoncandy as cc; import numpy as np
cci = cc.get_encrypted_interface(os.environ['DL_BUCKET'], verbose=False, ACCESS_KEY=os.environ['DL_ACCESS_KEY'], SECRET_KEY=os.environ['DL_SECRET_KEY'], endpoint_url=os.environ['DL_URL'])
a = np.arange(10)
cci.upload_raw_array('test_array', a)
assert np.allclose(a, cci.download_raw_array(a))

I can enable all existing tests to also run for encrypted interfaces, but this doubles testing time so I haven't included it here (but I can if that's not an issue).

@kroq-gar78 kroq-gar78 marked this pull request as ready for review September 30, 2024 02:31
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 this pull request may close these issues.

1 participant