I use this PHP code to encrypt a string:
use ParagonIE\Halite\KeyFactory;
use ParagonIE\Halite\Symmetric\Crypto as Symmetric;
use ParagonIE\HiddenString\HiddenString;
define("SECURE_PLACE", '/home/htdocs/secure_place/encryption.key');
/*
//already generated
$enc_key = KeyFactory::generateEncryptionKey();
KeyFactory::save($enc_key, $secure_place);
*/
$enc_key = KeyFactory::loadEncryptionKey(SECURE_PLACE);
$string = "String to be encrypted";
$cipherstring = \ParagonIE\Halite\Symmetric\Crypto::encrypt(
new HiddenString(
$string
),
$enc_key
);
I could decrypt it in PHP with:
$string = \ParagonIE\Halite\Symmetric\Crypto::decrypt(
$cipherstring,
$enc_key
);
but I need this to be done in Python3, as I am going to POST send the encrypted string to an AWS lambda handler.py function.
I know Halite is a PHP library, but I also understand that it is a wrapper for Libsodium, which is "a portable, cross-compilable, installable, packageable fork of NaCl, with a compatible API, and an extended API to improve usability even further."
Does anyone know which dependency should I use in Python3 (providing the code, if possible) to get the string decrypted? I guess I will need to set enc_key as a Lambda environment variable.