From 89a43b62c4c44f9b2ad954cad36be1cb5cef520f Mon Sep 17 00:00:00 2001 From: rorywhite200 <125914446+rorywhite200@users.noreply.github.com> Date: Fri, 26 Jan 2024 12:32:56 -0800 Subject: [PATCH] add documentation for generate_password & update function to remove print statement --- docs/example.ipynb | 116 ++++++++++++++++++++++++++- src/passwordler/generate_password.py | 1 - 2 files changed, 112 insertions(+), 5 deletions(-) diff --git a/docs/example.ipynb b/docs/example.ipynb index 6f08c42..805c2c0 100644 --- a/docs/example.ipynb +++ b/docs/example.ipynb @@ -18,9 +18,16 @@ "For the past 10 years, Bob has been using the password 'baseball' for all his online accounts. While this made them easy to remember, it also made them easy to hack. Unfortunately for Bob, some not-so-flattering photos of his trip to Cancun were sent to **all** of his Facebook friends (think sunglasses burn). Due to this incident, Bob has decided to up his password security and begins by testing the strength of his previously used password. " ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Password Strength" + ] + }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -96,12 +103,113 @@ "Finally! Something Bob can work with, he's found a password he likes that is also strong. But then Bob reads about our password generator and decides to give that a try instead." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Generate Password\n", + "\n", + "The `generate_password` function allows users to create a secure, customized password.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### First try: default settings\n", + "\n", + "Bob creates a password with the default settings. This returns a password of length 12, with at least one uppercase letter, number and symbol. " + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'`iw:XP-t<32J'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from passwordler.generate_password import generate_password\n", + "\n", + "generate_password()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Going for Length" + ] + }, + { + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "Intrigued, Bob decides to generate a much longer password, setting the `length` to 100 characters. The minimum accepted length is 12 characters." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'@iWD9x4j^_UM7}Qd46NV[@-dz^qD/i^qSnzP\"yg#eOLy7\\'|emw/Y>ZCDt3GiDi\\'.M7$2zxv&r\\'m>GO_EZ&dlY?OMw9JvjL`4%E>>'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "generate_password(length=100)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Simplifying It" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, he experiments with the `include_symbols` and `include_numbers` arguments. He sets both to false, overriding the default settings. This gives him a password with only letters: removing symbols and numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'cHaJeZNKwGrh'" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "generate_password(include_symbols=False, include_numbers=False)" + ] } ], "metadata": { diff --git a/src/passwordler/generate_password.py b/src/passwordler/generate_password.py index f0206cb..1a452a6 100644 --- a/src/passwordler/generate_password.py +++ b/src/passwordler/generate_password.py @@ -49,5 +49,4 @@ def generate_password(length=12, include_symbols=True, include_numbers=True): random.shuffle(password_characters) final_password = ''.join(password_characters) - print(f'Your password is: {final_password}') return final_password \ No newline at end of file