Skip to content

Commit

Permalink
kelar
Browse files Browse the repository at this point in the history
  • Loading branch information
Riveong committed Nov 27, 2023
1 parent 310d719 commit f7c109f
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,19 @@ def get_tutor(specialization = None, category = None):
"picture":x[10]
}
if specialization is not None and tutor_items["Specialization"].lower().find(specialization.lower()) != -1:
tutors.append(tutor_items)
if category is not None and tutor_items["Categories"] == category:
tutors.append(tutor_items)
elif category is None:
tutors.append(tutor_items)


elif specialization is None:
tutors.append(tutor_items)
if category is not None and tutor_items["Categories"] == category:
tutors.append(tutor_items)
elif category is None:
tutors.append(tutor_items)



mycursor.close()
close_db_connection(mydb, "User")
Expand Down
158 changes: 158 additions & 0 deletions main.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b'9Mytyik331FtUjVdAjbyGsZYrAmA5HEZ3ySySkJxJxA='"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from cryptography.fernet import Fernet\n",
"# Put this somewhere safe!\n",
"decrypt_key = Fernet.generate_key()\n",
"decrypt_key\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 96,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"b'gAAAAABlVkQM7Jb2gWUbWxhVpGLO8V0L747bKaKEdHCQrd2PtS4uGbR8XovVpH-2an0KbGeT5KwjEe9JHzIXqoBugcRaA2td4A=='\n",
"b'bro idk'\n"
]
}
],
"source": [
"\n",
"\n",
"f = Fernet(decrypt_key)\n",
"token = f.encrypt(b\"bro idk\")\n",
"print(token)\n",
"\n",
"token = f.decrypt(token)\n",
"print(token)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b'gAAAAABlVjCh2EsDx4if1T2YMWlN0AVeauRYp-LLv6GLtyAIcGM7DTrbrCmNyp2_Yl5J621GwYd9CdDO8k2bqmWVW260egMIkw=='"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"def password_encryption(encrypt_key, password):\n",
" f = Fernet(encrypt_key)\n",
" token = f.encrypt(password)\n",
" return token\n",
"\n",
"key = b'UChG_X63zHcFmtbXbREaK0-jeCG0mOxMb7lFiRnkegI='\n",
"password=\"aaa32423\"\n",
"password_bytes = password.encode('utf-8')\n",
"password_encryption(key, password_bytes)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b'gAAAAABlVjCh2EsDx4if1T2YMWlN0AVeauRYp-LLv6GLtyAIcGM7DTrbrCmNyp2_Yl5J621GwYd9CdDO8k2bqmWVW260egMIkw=='"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def password_encryption(encrypt_key, password):\n",
" f = Fernet(encrypt_key)\n",
" token = f.encrypt(password)\n",
" return token\n",
"\n",
"key = b'UChG_X63zHcFmtbXbREaK0-jeCG0mOxMb7lFiRnkegI='\n",
"password=\"aaa32423\"\n",
"password_bytes = password.encode('utf-8')\n",
"password_encryption(key, password_bytes)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b'aaa32423'"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def password_decryption(encrypt_key, password):\n",
" f = Fernet(encrypt_key)\n",
" token = f.decrypt(password)\n",
" return token\n",
"\n",
"key = b'UChG_X63zHcFmtbXbREaK0-jeCG0mOxMb7lFiRnkegI='\n",
"password= b'gAAAAABlVjCh2EsDx4if1T2YMWlN0AVeauRYp-LLv6GLtyAIcGM7DTrbrCmNyp2_Yl5J621GwYd9CdDO8k2bqmWVW260egMIkw=='\n",
"\n",
"password_decryption(key, password)\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit f7c109f

Please sign in to comment.