加密¶
Hash helpers used by the signing utilities.
get_md5_of_str(string)
¶
get_sha256_of_str(string)
¶
hash_base62(s, length=6)
¶
Return a Base62-encoded hash of a string with specified length.
Source code in aloha/encrypt/hash.py
hash_dict(dic)
¶
JWT encode/decode helpers.
decode(secret_key, token, **kwargs)
¶
Decode a JWT token and return either the payload or an error string.
Source code in aloha/encrypt/jwt.py
encode(secret_key, payload, headers=None, **kwargs)
¶
AES encrypt/decrypt helpers.
AesEncryptor
¶
Encrypt and decrypt strings with a selectable AES cipher profile.
Source code in aloha/encrypt/aes.py
__init__(key=None, key_size=16, cipher_name='AES/ECB/PKCS5Padding')
¶
Initialize the AES key and cipher settings.
Source code in aloha/encrypt/aes.py
decrypt(text, input_format='hex', func_unpad=None)
¶
Decrypt ciphertext produced by :meth:encrypt.
Source code in aloha/encrypt/aes.py
encrypt(text, output_format='hex', func_pad=None)
¶
Encrypt a UTF-8 string and return hex, base64, or raw bytes.
Source code in aloha/encrypt/aes.py
main()
¶
RSA encrypt/decrypt and signing helpers.
RsaEncryptor
¶
Encrypt, decrypt, and convert RSA keys and payloads.
Source code in aloha/encrypt/rsa.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
__init__(key_private=None, key_public=None, cipher_name='RSA/ECB/PKCS1Padding')
¶
Load optional keys and select a cipher profile.
Source code in aloha/encrypt/rsa.py
convert_base64_to_bytes(data)
staticmethod
¶
convert_bytes_to_base64(data)
staticmethod
¶
decrypt_with_private_key(ciphertext, key_private=None, cipher_name=None, **kwargs)
¶
Decrypt ciphertext with a private key.
Source code in aloha/encrypt/rsa.py
encrypt_with_public_key(message, key_public=None, cipher_name=None)
¶
Encrypt a message with a public key.
Source code in aloha/encrypt/rsa.py
generate_key_pair(size=1024)
staticmethod
¶
Generate a PEM-encoded RSA key pair.
Source code in aloha/encrypt/rsa.py
get_cipher(key_public=None, cipher_name='RSA/ECB/PKCS1Padding')
cached
¶
Return a cached public-key cipher instance.
Source code in aloha/encrypt/rsa.py
get_decipher(key_private=None, cipher_name='RSA/ECB/PKCS1Padding')
cached
¶
Return a cached private-key decipher instance.
Source code in aloha/encrypt/rsa.py
load_keys_from_binary(key_private=None, key_public=None)
staticmethod
¶
Load RSA keys from PEM/DER bytes.
Source code in aloha/encrypt/rsa.py
load_keys_from_string(key_private=None, key_public=None)
staticmethod
¶
Load RSA keys from PEM-like strings.
Source code in aloha/encrypt/rsa.py
main()
¶
Small self-test for the RSA helper.
Source code in aloha/encrypt/rsa.py
AesVault
¶
Bases: AesEncryptor, BaseVault
Password vault that stores encrypted secrets with AES.
Source code in aloha/encrypt/vault/plain.py
__init__(key=None)
¶
BaseVault
¶
Bases: ABC
Abstract base class for password vault implementations.
Source code in aloha/encrypt/vault/base.py
decrypt_password(*args, **kwargs)
abstractmethod
¶
get_password(password, *args, **kwargs)
¶
Return a password, optionally URL-encoded.
Source code in aloha/encrypt/vault/base.py
CyberArkVault
¶
Bases: BaseVault, AesEncryptor
Fetch and decrypt passwords from a CyberArk-compatible endpoint.
Source code in aloha/encrypt/vault/cyberark.py
__init__(url, app_id, key=None, safe='AIM_ELIS_LAS', folder='root')
¶
Initialize the vault with the CyberArk endpoint and credentials.
Source code in aloha/encrypt/vault/cyberark.py
decrypt_password(text)
¶
Decrypt the AES-encrypted password returned by CyberArk.
Source code in aloha/encrypt/vault/cyberark.py
get_cyberark_password(object=None, **kwargs)
¶
Request and decrypt a password from the CyberArk endpoint.
Source code in aloha/encrypt/vault/cyberark.py
get_password(object=None, **kwargs)
¶
Return a cached CyberArk password, optionally URL-encoded.
Source code in aloha/encrypt/vault/cyberark.py
get_sign(appid, keyvalue)
staticmethod
¶
Generate the CyberArk request signature.
Password vault abstraction used by database and service helpers.
BaseVault
¶
Bases: ABC
Abstract base class for password vault implementations.
Source code in aloha/encrypt/vault/base.py
decrypt_password(*args, **kwargs)
abstractmethod
¶
get_password(password, *args, **kwargs)
¶
Return a password, optionally URL-encoded.
Source code in aloha/encrypt/vault/base.py
AES-backed password vault helpers.
AesVault
¶
Bases: AesEncryptor, BaseVault
Password vault that stores encrypted secrets with AES.
Source code in aloha/encrypt/vault/plain.py
__init__(key=None)
¶
CyberArk-based password vault helpers.
CyberArkVault
¶
Bases: BaseVault, AesEncryptor
Fetch and decrypt passwords from a CyberArk-compatible endpoint.
Source code in aloha/encrypt/vault/cyberark.py
__init__(url, app_id, key=None, safe='AIM_ELIS_LAS', folder='root')
¶
Initialize the vault with the CyberArk endpoint and credentials.
Source code in aloha/encrypt/vault/cyberark.py
decrypt_password(text)
¶
Decrypt the AES-encrypted password returned by CyberArk.
Source code in aloha/encrypt/vault/cyberark.py
get_cyberark_password(object=None, **kwargs)
¶
Request and decrypt a password from the CyberArk endpoint.
Source code in aloha/encrypt/vault/cyberark.py
get_password(object=None, **kwargs)
¶
Return a cached CyberArk password, optionally URL-encoded.
Source code in aloha/encrypt/vault/cyberark.py
get_sign(appid, keyvalue)
staticmethod
¶
Generate the CyberArk request signature.
main()
¶
Small self-test scaffold for the CyberArk vault.