added workfile to manage pwds and save them to the os keyring
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Import Libaries"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"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": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"login = 10730196\n",
|
||||
"password = '#mDJu9O3'\n",
|
||||
"server = 'VantageInternational-Demo'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"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": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"#mDJu9O3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(kr.get_password(server,str(login)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Retrievieng Credentials"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Username : 10730196\n",
|
||||
"Password : #mDJu9O3\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": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"kr.delete_password(server, str(login)) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"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
|
||||
}
|
||||
Reference in New Issue
Block a user