{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Import Libaries" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import keyring as kr" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Save Pwd to keyring\n", "\n", "- **servicename** – The name of the service i.e to a certain organization with which the person is related to.\n", "- **username** – Username of the person.\n", "- **password** – Password associated with that username.\n", "\n", "```python\n", "kr.set_password(\"servicename\",\"username\",\"pwd\")\n", "```\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Live Acccount\n", "login = 10676507\n", "password = '5l5^hbEL'\n", "server = 'VantageInternational-Live 4'" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# Demo Acccount\n", "login = 10800246\n", "password = '%dN!Zu96'\n", "server = 'VantageInternational-Demo'" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "kr.set_password(server, str(login), password)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Get Password\n", "\n", "To retrieve the saved password we will use the get_password() method. It takes two parameters.\n", "\n", "- Servicename\n", "- Username\n", "\n", "```python\n", "print(kr.get_password(\"Servicename\",\"Username\"))\n", "```" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5l5^hbEL\n" ] } ], "source": [ "print(kr.get_password(server,str(login)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Retrievieng Credentials" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Username : 10676507\n", "Password : 5l5^hbEL\n" ] } ], "source": [ "cred = kr.get_credential(server,\"\") \n", " \n", "print(\"Username : \",cred.username) \n", "print(\"Password : \",cred.password)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Delete from Keyring\n", "\n", "To delete a password we will use the delete_password() method. It also takes two parameters:\n", "\n", "- Servicename\n", "- Username\n", "\n", "```python\n", "kr.delete_password(\"Servicename\", \"Username\") \n", "```" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "kr.delete_password(server, str(login)) " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "None\n" ] } ], "source": [ "print(kr.get_password(server, str(login)))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 2 }