This repository contains a Python 3 script that was created for the Polytechnic University of Puerto Rico's American Society of Civil Engineers Student Chapter. This little script enables the user to encrypt via hashing. Currently, the program is able to hash strings with SHA256, SHA512-256, SHA3-256 and SM3, as per the requirements provided by the organization.
The script was developed in Visual Studio Code with Python 3 and Python 3's Pyca Cryptography Library. Moreover, this program was developed using the Windows OS.
In order to install and use this script, it is recomended to create a Python Virtual Enviroment. This can be done easily via Visual Studio Code with its built-in Terminal, as so:
- Look at Visual Studio Code's toolbar until you see the Terminal option. Now, go to Terminal -> New Terminal, and a new terminal should appear on your compter screen.
- If not already in, look for the folder with the downloaded reposity with Visual Studio Code and open it.
- Type the following commands, one after the other. Remember to press Enter to move the cursos to a new line and run the previous command.
python -m venv venv
venv/Scripts/activate
Now, with the Python Virtual Enviroment already created and activated, one should now download all the necesary dependencies for the the asce_crypt.py to work. This is shown as follows:
pip install -r requirements.txt
It should be noted that the dependencies that pip will download are:
- cffi==1.15.1
- cryptography==41.0.4
- pycparser==2.21
The asce_crypt.py script has the following parameters, namely:
- password: As per the name of this parameter, it can be considered as the password text. With that being said, it is the plain text that the user of this application would want hashed.
- -ha: This parameter defines the algorithm that the program will use to hash the value of the password parameter. The possible algorithms include: SHA256, SHA512-256, SHA3-256 and SM3.
- -r: This parameter represents the number of times the password parameter value will be hashed via the -ha method.
- -h: Outputs the help for the program.
An example of the usage of this program is shown in the following code:
(venv) PS C:\...\Crypt> python src/asce_crypt.py -ha SHA256 -r 1 123
a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3