robotframework-crypto


Namerobotframework-crypto JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/Snooz82/robotframework-crypto
SummaryA library for secure password handling.
upload_time2024-12-06 19:58:47
maintainerNone
docs_urlNone
authorRené Rohner(Snooz82)
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
===================================================
robotframework-crypto
===================================================

CryptoLibrary is a library for secure password handling.
`project page <https://github.com/Snooz82/robotframework-crypto>`_

For more information about Robot Framework, see http://robotframework.org.

`Keyword Documentation <https://snooz82.github.io/robotframework-crypto/CryptoLibrary.html>`_

|

Installation
------------

If you already have Python >= 3.6 with pip installed, you can simply
run:

``pip install --upgrade robotframework-crypto``

or if you have Python 2 and 3 installed in parallel you may use

``pip3 install --upgrade robotframework-crypto``

If you have Python 2 ... i am very sorry! Please update!

|

How it works
------------

CryptoLibrary uses asymmetric crypto with elliptic curve cryptography to store confidential data securely.

With the command ``CryptoLibrary`` in 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+xSlmzT3dcvfrTL9wIdRwmNOJuONT7FBW5``

This 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 with ``python -m CryptoLibrary`` .

|

Suppressing encrypted Text from Logs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All 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
~~~~~~~~~~~~~

.. code :: robotframework

    *** Settings ***
    Resource    imports.resource
    Library     CryptoLibrary    %{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 Login
        Open 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 text
        Input Text      id:input_username    ${user}
        ${password}=    Get Decrypted Text    ${enc_pwd}  #decrypts cipher text and returns plain text
        Input Password    id:input_password    ${password}
        Click Button    id:button_login
        Page Should Contain Element    //a[text()='Logout']
        [Teardown]   Close Browser

in this case the decryption password for the private key.
It can also be saved on test env persistently as a hash.

The parameter **variable_decryption** in 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 CryptoLibrary
~~~~~~~~~~~~~~~~~~~~~~~~~~

+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| **password:**            | 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 to ``True`` all 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 to ``cryptoutility.py``.                                                                                   |
+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+

|

Menu walkthrough
----------------

|

CryptoLibrary Command Line Tool
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This 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 -m CryptoLibrary``::

 ? 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, start ``python -m CryptoLibrary`` and choose ``Open config`` -> ``Configure key pair``-> ``Generate key pair``.

This generates the private and public keys in the ``private_key.json`` and ``public_key.key`` files.
The ``private_key.json`` is needed to decrypt the values on your test server and has to be copied manually or added through the CLI interface.
See ``Set key pair from...`` above.

Next you can encrypt the values needed on your test server, looking something like ``crypt:nkpEPOVKfOko3t04XxOupA+F/ANTEuR9aQuPaPeMBGBQenwYf6UNESEl9MWRKGuj60ZWd10=``

There are two options to decrypt your values in the robot file. When CryptoLibrary is loaded with ``variable_decryption=True``,
ALL variables defined in that section, will automatically get decrypted.
When the option is turned off (the default) the keyword ``Get Decrypted Text`` explicitly decrypts specific values.

|

CryptoClient Command Line Tool
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This 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 -m CryptoClient``::

 ? 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?
                        Back

|

SeleniumLibrary Plugin
----------------------

CryptoLibrary.Plugin is a SeleniumLibrary Plugin.
When taken into usage, the ``Input Password`` Keyword can now handle decrypted cipher texts as well.

Example:

.. code :: robotframework

    *** Settings ***
    Library    SeleniumLibrary    plugins=CryptoLibrary.Plugin


    *** Variables ***
    ${Admins-Password}=    crypt:fQ5Iqn/j2lN8rXwimyz0JXlYzD0gTsPRwb0YJ3YSvDchkvDpfwYDmhHxsZ2i7bIQDlsWKJVhBb+Dz4w=


    *** Test Cases ***
    Decrypt as Plugin
        Open Browser      http://www.keyword-driven.de
        Input Text        input_username    admin
        Input Password    input_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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Snooz82/robotframework-crypto",
    "name": "robotframework-crypto",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ren\u00e9 Rohner(Snooz82)",
    "author_email": "snooz@posteo.de",
    "download_url": "https://files.pythonhosted.org/packages/13/66/6ba398c4d0f4f2590529c0e26d60dbc6e7a90ec5f4e36acac00e53e1333a/robotframework-crypto-0.4.1.tar.gz",
    "platform": null,
    "description": "\n===================================================\nrobotframework-crypto\n===================================================\n\nCryptoLibrary is a library for secure password handling.\n`project page <https://github.com/Snooz82/robotframework-crypto>`_\n\nFor more information about Robot Framework, see http://robotframework.org.\n\n`Keyword Documentation <https://snooz82.github.io/robotframework-crypto/CryptoLibrary.html>`_\n\n|\n\nInstallation\n------------\n\nIf you already have Python >= 3.6 with pip installed, you can simply\nrun:\n\n``pip install --upgrade robotframework-crypto``\n\nor if you have Python 2 and 3 installed in parallel you may use\n\n``pip3 install --upgrade robotframework-crypto``\n\nIf you have Python 2 ... i am very sorry! Please update!\n\n|\n\nHow it works\n------------\n\nCryptoLibrary uses asymmetric crypto with elliptic curve cryptography to store confidential data securely.\n\nWith the command ``CryptoLibrary`` in console/terminal you can generate a key pair\n(private and public key) for your test env.\nYou will get the public key after generating.\n\nThis public key can now be used to encrypt every data you do not want to be public.\nPasswords, personal data, etc.\n\nYou can use the command``CryptoClient`` on you computer where you want to encrypt data.\n\nEncrypted Data will look like this:\n\n``crypt:tIdr5s65+ggfJZl46pJgljioCUePUdZLozgiwquznw+xSlmzT3dcvfrTL9wIdRwmNOJuONT7FBW5``\n\nThis encrypted data can now be decrypted with CryptoLibrary within Robot Framework.\n\nCryptoLibrary need the private_key_store.json for this.\nThis is what is generated as key pair.\nPrivate key can be imported in test env with ``python -m CryptoLibrary`` .\n\n|\n\nSuppressing encrypted Text from Logs\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAll Data that is decrypted by CryptoLibrary is replaced in the log by ``***``\nThis works always and can not be disabled.\nNo need to use special keywords for this.\n\n|\n\nUsage in Test\n~~~~~~~~~~~~~\n\n.. code :: robotframework\n\n    *** Settings ***\n    Resource    imports.resource\n    Library     CryptoLibrary    %{private_key_password}    variable_decryption=False\n    #private key which should be secret, should also be protected by a password\n\n    *** Variables ***\n    ${secret}=     KILL ALL HUMANS!!!\n    ${enc_user}=   crypt:nkpEPOVKfOko3t04XxOupA+F/ANTEuR9aQuPaPeMBGBQenwYf6UNESEl9MWRKGuj60ZWd10=\n    ${enc_pwd}=    crypt:TVpamLXCtrzRsl8UAgD0YuoY+lSJNV73+bTYhOP51zM1GQihgyCvSZ2CoGoKsUHLFjokyJLHxFzPEB4=\n\n    *** Test Cases ***\n    Valid Login\n        Open Browser    ${BASE-URL}\n        Suppress Logging                                  #disable Robot Framework logging\n        ${var}=    set Variable   ${secret}\n        Log    ${var}\n        Unsuppress Logging                                #enable Robot Framework logging\n        ${user}=    Get Decrypted Text    ${enc_user}     #decrypts cipher text and returns plain text\n        Input Text      id:input_username    ${user}\n        ${password}=    Get Decrypted Text    ${enc_pwd}  #decrypts cipher text and returns plain text\n        Input Password    id:input_password    ${password}\n        Click Button    id:button_login\n        Page Should Contain Element    //a[text()='Logout']\n        [Teardown]   Close Browser\n\nin this case the decryption password for the private key.\nIt can also be saved on test env persistently as a hash.\n\nThe parameter **variable_decryption** in the Library call, if set to true it will automatically decode ALL passwords defined in the variables section\nand then ``\"Get Decrypted Text\"`` isn't needed.\n\n|\n\nImporting of CryptoLibrary\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| **password:**            | Password for private key can be given as argument. This should be stored as secret! Use environment variables instead of hard coding it here.            |\n+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| **variable_decryption:** | If set to ``True`` all variables that are available on Test Suite or on Test Case start,                                                                 |\n|                          | that contain a encrypted text, will be decrypted automatically.                                                                                          |\n+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| **key_path:**            | A path that defines where the key pair is stored physically.                                                                                             |\n|                          | Path needs to be an absolute path or relative to ``cryptoutility.py``.                                                                                   |\n+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n\n|\n\nMenu walkthrough\n----------------\n\n|\n\nCryptoLibrary Command Line Tool\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis Command Line tool has to be used to create a key pair.\nIt can also show the public key and encrypt or decrypt data.\n\n``python -m CryptoLibrary``::\n\n ? What do you want to do?  (Use arrow keys)\n   Encrypt\n   Decrypt\n   Open config --->  ? What do you want to do?  (Use arrow keys)\n   Quit                 Configure key pair    ----------------------------------------------------------------------------------------->  ? What do you want to do?  (Use arrow keys)\n                        Configure public key  --->  ? What do you want to do?  (Use arrow keys)                                             Generate key pair\n                        Back                          Set public key from string  --->   ? Input public_key as Base64:  ThePublicKey        Set key path\n                                                      Get public key from string  --->   Public Key: ThePublicKey                           Set key pair from string\n                                                      Delete public key           --->   ? Do you really want to delete public key?         Delete key pair\n                                                      Back                                                                                  Save private key password\n                                                                                                                                            Delete saved password\n                                                                                                                                            Back\n ? What do you want to do?  (Use arrow keys)\n   Encrypt     ------------------------------------------------------------------->   ? Enter the password to encrypt  YourPassword\n   Decrypt     -----> ? Input encrypted cipher text:  crypt:TheEncryptedPassword      Encrypted password: (use inlc. \"crypt:\")\n   Open config        ? Enter the password to decrypt  **********\n   Quit               Your password is: YourPassword                                  crypt:TheEncryptedPassword=\n\nTo start using the CryptoLibrary, start ``python -m CryptoLibrary`` and choose ``Open config`` -> ``Configure key pair``-> ``Generate key pair``.\n\nThis generates the private and public keys in the ``private_key.json`` and ``public_key.key`` files.\nThe ``private_key.json`` is needed to decrypt the values on your test server and has to be copied manually or added through the CLI interface.\nSee ``Set key pair from...`` above.\n\nNext you can encrypt the values needed on your test server, looking something like ``crypt:nkpEPOVKfOko3t04XxOupA+F/ANTEuR9aQuPaPeMBGBQenwYf6UNESEl9MWRKGuj60ZWd10=``\n\nThere are two options to decrypt your values in the robot file. When CryptoLibrary is loaded with ``variable_decryption=True``,\nALL variables defined in that section, will automatically get decrypted.\nWhen the option is turned off (the default) the keyword ``Get Decrypted Text`` explicitly decrypts specific values.\n\n|\n\nCryptoClient Command Line Tool\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis CryptoClient command line tool is the tool for all test designers that want to encrypt data.\nI can only import and show the public key and encrypt data.\n\n``python -m CryptoClient``::\n\n ? What do you want to do?  (Use arrow keys)\n   Encrypt     --------------------------------------------------------------------------------------->   ? Enter the password to encrypt  YourPassword\n   Open config -----> ? What do you want to do?  (Use arrow keys)                                           Encrypted password: (use inlc. \"crypt:\")\n   Quit                 Set public key from string  --->   ? Input public_key as Base64:  ThePublicKey\n                        Get public key from string  --->   Public Key: ThePublicKey                         crypt:TheEncryptedPassword\n                        Delete public key           --->   ? Do you really want to delete public key?\n                        Back\n\n|\n\nSeleniumLibrary Plugin\n----------------------\n\nCryptoLibrary.Plugin is a SeleniumLibrary Plugin.\nWhen taken into usage, the ``Input Password`` Keyword can now handle decrypted cipher texts as well.\n\nExample:\n\n.. code :: robotframework\n\n    *** Settings ***\n    Library    SeleniumLibrary    plugins=CryptoLibrary.Plugin\n\n\n    *** Variables ***\n    ${Admins-Password}=    crypt:fQ5Iqn/j2lN8rXwimyz0JXlYzD0gTsPRwb0YJ3YSvDchkvDpfwYDmhHxsZ2i7bIQDlsWKJVhBb+Dz4w=\n\n\n    *** Test Cases ***\n    Decrypt as Plugin\n        Open Browser      http://www.keyword-driven.de\n        Input Text        input_username    admin\n        Input Password    input_password    ${Admins-Password}\n\n|\n\n\nIt may happen that keywords changes.\ni try not to do, but it can happen in major releases.\nFeel free to make a pull Request to improve docs or write some tests for it.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A library for secure password handling.",
    "version": "0.4.1",
    "project_urls": {
        "Homepage": "https://github.com/Snooz82/robotframework-crypto"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c727634cf1d76819c3e67549ad83ee121fbb59f025d73f25c7f25fd2b97f420",
                "md5": "5c8e9b964f1216567e76132e9840cf71",
                "sha256": "54a4e65c9813782ca31cfa142d37d22eea4697aa21942afeff40e8c3d25fe396"
            },
            "downloads": -1,
            "filename": "robotframework_crypto-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5c8e9b964f1216567e76132e9840cf71",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 22222,
            "upload_time": "2024-12-06T19:58:45",
            "upload_time_iso_8601": "2024-12-06T19:58:45.633905Z",
            "url": "https://files.pythonhosted.org/packages/9c/72/7634cf1d76819c3e67549ad83ee121fbb59f025d73f25c7f25fd2b97f420/robotframework_crypto-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "13666ba398c4d0f4f2590529c0e26d60dbc6e7a90ec5f4e36acac00e53e1333a",
                "md5": "61ef9ac8dca6d16e7545066daa09f346",
                "sha256": "ada2009b8dd2d21cf7dd61c9da8d9b9af9dd3ce603e1e229105c22c1b24b5835"
            },
            "downloads": -1,
            "filename": "robotframework-crypto-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "61ef9ac8dca6d16e7545066daa09f346",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 76175,
            "upload_time": "2024-12-06T19:58:47",
            "upload_time_iso_8601": "2024-12-06T19:58:47.650924Z",
            "url": "https://files.pythonhosted.org/packages/13/66/6ba398c4d0f4f2590529c0e26d60dbc6e7a90ec5f4e36acac00e53e1333a/robotframework-crypto-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-06 19:58:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Snooz82",
    "github_project": "robotframework-crypto",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "robotframework-crypto"
}
        
Elapsed time: 1.02610s