Make PyCryptodome an optional dependency
This commit is contained in:
parent
3626d3037f
commit
7730ce476a
@ -46,6 +46,7 @@ The mandatory dependencies of this library are:
|
|||||||
Optional dependencies are:
|
Optional dependencies are:
|
||||||
|
|
||||||
* [mpmath](https://mpmath.org/), for *beta_ratio* and *beta_oddsratio*
|
* [mpmath](https://mpmath.org/), for *beta_ratio* and *beta_oddsratio*
|
||||||
|
* [PyCryptodome](https://www.pycryptodome.org/), for *pickle_write_encrypted* and *pickle_read_encrypted*
|
||||||
* [rpy2](https://rpy2.github.io/), with R packages:
|
* [rpy2](https://rpy2.github.io/), with R packages:
|
||||||
* [BFpack](https://cran.r-project.org/web/packages/BFpack/index.html), for *bayesfactor_afbf* (*RegressionResult.bayesfactor_beta_zero*)
|
* [BFpack](https://cran.r-project.org/web/packages/BFpack/index.html), for *bayesfactor_afbf* (*RegressionResult.bayesfactor_beta_zero*)
|
||||||
* [logistf](https://cran.r-project.org/web/packages/logistf/index.html), for *PenalisedLogit*
|
* [logistf](https://cran.r-project.org/web/packages/logistf/index.html), for *PenalisedLogit*
|
||||||
|
11
yli/io.py
11
yli/io.py
@ -14,10 +14,6 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from Crypto.Cipher import AES
|
|
||||||
from Crypto.Protocol.KDF import scrypt
|
|
||||||
from Crypto.Random import get_random_bytes
|
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
import io
|
import io
|
||||||
import lzma
|
import lzma
|
||||||
@ -32,6 +28,10 @@ def pickle_write_encrypted(df, fname):
|
|||||||
Password is derived using scrypt KDF
|
Password is derived using scrypt KDF
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from Crypto.Cipher import AES
|
||||||
|
from Crypto.Protocol.KDF import scrypt
|
||||||
|
from Crypto.Random import get_random_bytes
|
||||||
|
|
||||||
# Get random salt
|
# Get random salt
|
||||||
salt = get_random_bytes(16)
|
salt = get_random_bytes(16)
|
||||||
|
|
||||||
@ -69,6 +69,9 @@ def pickle_read_encrypted(fname):
|
|||||||
Read a DataFrame from an encrypted file
|
Read a DataFrame from an encrypted file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from Crypto.Cipher import AES
|
||||||
|
from Crypto.Protocol.KDF import scrypt
|
||||||
|
|
||||||
# Read ciphertext data
|
# Read ciphertext data
|
||||||
with open(fname, 'rb') as f:
|
with open(fname, 'rb') as f:
|
||||||
salt, nonce, ct_bytes = pickle.load(f)
|
salt, nonce, ct_bytes = pickle.load(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user