Package: robotframework-crypto
CryptoLibrary is a library for secure password handling.project pageFor more information about Robot Framework, seehttp://robotframework.org.Keyword DocumentationInstallationIf you already have Python >= 3.6 with pip installed, you can simply
run:pip install--upgraderobotframework-cryptoor if you have Python 2 and 3 installed in parallel you may usepip3 install--upgraderobotframework-cryptoIf you have Python 2 … i am very sorry! Please update!How it worksCryptoLibrary uses asymmetric crypto with elliptic curve cryptography to store confidential data securely.With the commandCryptoLibraryin console/terminal you can generate a key pair
(private and public key) for your test env.
You will get the public key after generating.This public key can now be used to encrypt every data you do not want to be public.
Passwords, personal data, etc.You can use the command``CryptoClient`` on you computer where you want to encrypt data.Encrypted Data will look like this:crypt:tIdr5s65+ggfJZl46pJgljioCUePUdZLozgiwquznw+xSlmzT3dcvfrTL9wIdRwmNOJuONT7FBW5This encrypted data can now be decrypted with CryptoLibrary within Robot Framework.CryptoLibrary need the private_key_store.json for this.
This is what is generated as key pair.
Private key can be imported in test env withpython-mCryptoLibrary.Suppressing encrypted Text from LogsAll Data that is decrypted by CryptoLibrary is replaced in the log by***This works always and can not be disabled.
No need to use special keywords for this.Usage in Test*** Settings ***Resourceimports.resourceLibraryCryptoLibrary%{private_key_password}variable_decryption=False#private key which should be secret, should also be protected by a password*** Variables ***${secret}=KILL ALL HUMANS!!!${enc_user}=crypt:nkpEPOVKfOko3t04XxOupA+F/ANTEuR9aQuPaPeMBGBQenwYf6UNESEl9MWRKGuj60ZWd10=${enc_pwd}=crypt:TVpamLXCtrzRsl8UAgD0YuoY+lSJNV73+bTYhOP51zM1GQihgyCvSZ2CoGoKsUHLFjokyJLHxFzPEB4=*** Test Cases ***Valid LoginOpen Browser${BASE-URL}Suppress Logging#disable Robot Framework logging${var}=set Variable${secret}Log${var}Unsuppress Logging#enable Robot Framework logging${user}=Get Decrypted Text${enc_user}#decrypts cipher text and returns plain textInput Textid:input_username${user}
    ${password}=Get Decrypted Text${enc_pwd}#decrypts cipher text and returns plain textInput Passwordid:input_password${password}Click Buttonid:button_loginPage Should Contain Element//a[text()='Logout'][Teardown]Close Browserin this case the decryption password for the private key.
It can also be saved on test env persistently as a hash.The parametervariable_decryptionin the Library call, if set to true it will automatically decode ALL passwords defined in the variables section
and then"Get Decrypted Text"isn’t needed.Importing of CryptoLibrarypassword:Password for private key can be given as argument. This should be stored as secret! Use environment variables instead of hard coding it here.variable_decryption:If set toTrueall variables that are available on Test Suite or on Test Case start,
that contain a encrypted text, will be decrypted automatically.key_path:A path that defines where the key pair is stored physically.
Path needs to be an absolute path or relative tocryptoutility.py.Menu walkthroughCryptoLibrary Command Line ToolThis Command Line tool has to be used to create a key pair.
It can also show the public key and encrypt or decrypt data.python-mCryptoLibrary:? What do you want to do?  (Use arrow keys)
  Encrypt
  Decrypt
  Open config --->  ? What do you want to do?  (Use arrow keys)
  Quit                 Configure key pair    ----------------------------------------------------------------------------------------->  ? What do you want to do?  (Use arrow keys)
                       Configure public key  --->  ? What do you want to do?  (Use arrow keys)                                             Generate key pair
                       Back                          Set public key from string  --->   ? Input public_key as Base64:  ThePublicKey        Set key path
                                                     Get public key from string  --->   Public Key: ThePublicKey                           Set key pair from string
                                                     Delete public key           --->   ? Do you really want to delete public key?         Delete key pair
                                                     Back                                                                                  Save private key password
                                                                                                                                           Delete saved password
                                                                                                                                           Back
? What do you want to do?  (Use arrow keys)
  Encrypt     ------------------------------------------------------------------->   ? Enter the password to encrypt  YourPassword
  Decrypt     -----> ? Input encrypted cipher text:  crypt:TheEncryptedPassword      Encrypted password: (use inlc. "crypt:")
  Open config        ? Enter the password to decrypt  **********
  Quit               Your password is: YourPassword                                  crypt:TheEncryptedPassword=To start using the CryptoLibrary, startpython-mCryptoLibraryand chooseOpen config->Configure key pair->Generate key pair.This generates the private and public keys in theprivate_key.jsonandpublic_key.keyfiles.
Theprivate_key.jsonis needed to decrypt the values on your test server and has to be copied manually or added through the CLI interface.
SeeSet key pairfrom...above.Next you can encrypt the values needed on your test server, looking something likecrypt:nkpEPOVKfOko3t04XxOupA+F/ANTEuR9aQuPaPeMBGBQenwYf6UNESEl9MWRKGuj60ZWd10=There are two options to decrypt your values in the robot file. When CryptoLibrary is loaded withvariable_decryption=True,
ALL variables defined in that section, will automatically get decrypted.
When the option is turned off (the default) the keywordGet Decrypted Textexplicitly decrypts specific values.CryptoClient Command Line ToolThis CryptoClient command line tool is the tool for all test designers that want to encrypt data.
I can only import and show the public key and encrypt data.python-mCryptoClient:? What do you want to do?  (Use arrow keys)
  Encrypt     --------------------------------------------------------------------------------------->   ? Enter the password to encrypt  YourPassword
  Open config -----> ? What do you want to do?  (Use arrow keys)                                           Encrypted password: (use inlc. "crypt:")
  Quit                 Set public key from string  --->   ? Input public_key as Base64:  ThePublicKey
                       Get public key from string  --->   Public Key: ThePublicKey                         crypt:TheEncryptedPassword
                       Delete public key           --->   ? Do you really want to delete public key?
                       BackSeleniumLibrary PluginCryptoLibrary.Plugin is a SeleniumLibrary Plugin.
When taken into usage, theInput PasswordKeyword can now handle decrypted cipher texts as well.Example:*** Settings ***LibrarySeleniumLibraryplugins=CryptoLibrary.Plugin*** Variables ***${Admins-Password}=crypt:fQ5Iqn/j2lN8rXwimyz0JXlYzD0gTsPRwb0YJ3YSvDchkvDpfwYDmhHxsZ2i7bIQDlsWKJVhBb+Dz4w=*** Test Cases ***Decrypt as PluginOpen Browserhttp://www.keyword-driven.deInput Textinput_usernameadminInput Passwordinput_password${Admins-Password}It may happen that keywords changes.
i try not to do, but it can happen in major releases.
Feel free to make a pull Request to improve docs or write some tests for it.