update module3.ipynb
This commit is contained in:
parent
b050e5c5bf
commit
f3386d3016
418
module3.ipynb
418
module3.ipynb
@ -821,14 +821,428 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Public vs. private keys"
|
||||
"# Public vs. private keys\n",
|
||||
"\n",
|
||||
"In a rapidly evolving world of technology, it is more critical than ever to establish security policies throughout an organization that safeguard valuable information and data assets. Asymmetric cryptography relies on public and private keys as its core building blocks to maintain data security and confidentiality in the face of dangers. However, to enable organizations to make wise decisions that will protect online interactions and information, it is important that we understand when public and private keys are used and how to do so effectively.\n",
|
||||
"\n",
|
||||
"## What is a public key?\n",
|
||||
"\n",
|
||||
"A public key is frequently employed to establish secure communication through data encryption or to validate the authenticity of a digital signature. Safety is ensured because the public key comes from a trusted certificate authority, which gives digital certificates verifying the owner’s identity and key. Public keys are created through an asymmetric algorithm that conducts several operations on a pair of connected keys before being transmitted over the internet.\n",
|
||||
"\n",
|
||||
"## What is a private key?\n",
|
||||
"\n",
|
||||
"A private key is a secret and secure key that must be kept confidential and protected. Its role involves decryption and the creation of digital signatures, assuring the data's integrity and authenticity. It is the counterpart of the public key and is shared to decrypt encoded information. Any data encrypted using the private key can be decrypted using the corresponding public key.\n",
|
||||
"\n",
|
||||
"## How do public and private keys work together?\n",
|
||||
"\n",
|
||||
"Public and private keys work together to ensure secure communication, data encryption, digital signatures, and key exchanges take place safely across various communication channels. This process encompasses:\n",
|
||||
"\n",
|
||||
"1. Key generation: A public and private key is generated for both the sender and receiver.\n",
|
||||
"2. Key exchange: The public keys are exchanged between sender and receiver.\n",
|
||||
"3. Encryption: The sender encrypts their data using the recipient's public key.\n",
|
||||
"4. Transmitting encrypted data: The encrypted data is transmitted to the recipient.\n",
|
||||
"5. Decryption: The recipient decrypts the message using their exclusive private key.\n",
|
||||
"\n",
|
||||
"## Key takeaway\n",
|
||||
"\n",
|
||||
"In summary, although public and private keys are distinct, they work together to create a powerful and flexible foundation for achieving data security, confidentiality, integrity, and authentication in a wide range of digital settings."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# The Pull-Merge-Push Workflow"
|
||||
"# The Pull-Merge-Push Workflow\n",
|
||||
"\n",
|
||||
"This reading contains the code used in the instructional videos from [**The Pull-Merge-Push Workflow**<svg aria-labelledby=\"cds-react-aria3604314262-:r5s5:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5s5:\"><title id=\"cds-react-aria3604314262-:r5s5:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/n3GnN/the-pull-merge-push-workflow)\n",
|
||||
"\n",
|
||||
"## Introduction\n",
|
||||
"\n",
|
||||
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course.\n",
|
||||
"\n",
|
||||
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"atom all\\_checks.py\n",
|
||||
"\n",
|
||||
"#!/usr/binenv python3\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"\n",
|
||||
"def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
|
||||
"\n",
|
||||
" \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
|
||||
"\n",
|
||||
" du = shutil.disk\\_usage(disk)\n",
|
||||
"\n",
|
||||
" # Calculate the percentage of free space\n",
|
||||
"\n",
|
||||
" percent\\_free = 100 \\* du.free / du.total\n",
|
||||
"\n",
|
||||
" # Calculate how many free gigabytes\n",
|
||||
"\n",
|
||||
" gigabytes\\_free = du.free / 2\\*\\*30\n",
|
||||
"\n",
|
||||
" if percent\\_free < min\\_percent or gigabytes\\_free < min\\_gb:\n",
|
||||
"\n",
|
||||
" return True\n",
|
||||
"\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"def main(): \n",
|
||||
"\n",
|
||||
" if check\\_reboot():\n",
|
||||
"\n",
|
||||
" print(\"Pending Reboot.\")\n",
|
||||
"\n",
|
||||
" sys\\_exit(1)\n",
|
||||
"\n",
|
||||
" if check\\_disk\\_full(disk=\"/\", min\\_gb=2, min\\_percent=10):\n",
|
||||
"\n",
|
||||
" print(\"Disk full.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
" print(\"Everything ok\")\n",
|
||||
"\n",
|
||||
" sys.exit(0)\n",
|
||||
"\n",
|
||||
"main()\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git add \\-p\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"index e46cdae..a40047c 100755\n",
|
||||
"\n",
|
||||
"\\--- a/all\\_checks.py\n",
|
||||
"\n",
|
||||
"+++ b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"@@ -8,14 +8,14 @@ def check\\_reboot():\n",
|
||||
"\n",
|
||||
" \"\"\"Returns True if the computer has a pending reboot.\"\"\"\n",
|
||||
"\n",
|
||||
" return os.path.exists(\"/run/reboot-required\")\n",
|
||||
"\n",
|
||||
"\\-def check\\_disk\\_full(disk, min\\_absolute, min\\_percent):\n",
|
||||
"\n",
|
||||
"+def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
|
||||
"\n",
|
||||
" \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
|
||||
"\n",
|
||||
" du = shutil.disk\\_usage(disk)\n",
|
||||
"\n",
|
||||
" # Calculate the percentage of free space\n",
|
||||
"\n",
|
||||
" percent\\_free = 100 \\* du.free / du.total\n",
|
||||
"\n",
|
||||
" # Calculate how many free gigabytes\n",
|
||||
"\n",
|
||||
" gigabytes\\_free = du.free / 2\\*\\*30\n",
|
||||
"\n",
|
||||
"\\- if percent\\_free < min\\_percent or gigabytes\\_free < min\\_absolute:\n",
|
||||
"\n",
|
||||
"+ if percent\\_free < min\\_percent or gigabytes\\_free < min\\_gb:\n",
|
||||
"\n",
|
||||
" return True\n",
|
||||
"\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"Stage this hunk \\[y,n,q,a,d,j,J,g,/,s,e,?\\]? y\n",
|
||||
"\n",
|
||||
"@@ -27,7 +27,7 @@ def main():\n",
|
||||
"\n",
|
||||
" if check\\_reboot():\n",
|
||||
"\n",
|
||||
" print(\"Pending Reboot.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
"\\- if check\\_disk\\_full(\"/\", 2, 10):\n",
|
||||
"\n",
|
||||
"+ if check\\_disk\\_full(disk=\"/\", min\\_gb=2, min\\_percent=10):\n",
|
||||
"\n",
|
||||
" print(\"Disk full.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
"Stage this hunk \\[y,n,q,a,d,K,g,/,e,?\\]? y\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git commit \\-m 'Rename min\\_absolute to min\\_gb, use parameter names'\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"\\[master 03923d0\\] Rename min\\_absolute to min\\_gb, use parameter names\n",
|
||||
"\n",
|
||||
" 1 file changed, 3 insertions(+), 3 deletions(-)\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git push\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"Username for 'https://github.com': redquinoa\n",
|
||||
"\n",
|
||||
"Password for 'https://redquinoa@github.com': \n",
|
||||
"\n",
|
||||
"To https://github.com/redquinoa/health-checks.git\n",
|
||||
"\n",
|
||||
" ! \\[rejected\\] master -> master (fetch first)\n",
|
||||
"\n",
|
||||
"error: failed to push some refs to 'https://github.com/redquinoa/health-checks.git'\n",
|
||||
"\n",
|
||||
"hint: Updates were rejected because the remote contains work that you do\n",
|
||||
"\n",
|
||||
"hint: not have locally. This is usually caused by another repository pushing\n",
|
||||
"\n",
|
||||
"hint: to the same ref. You may want to first integrate the remote changes\n",
|
||||
"\n",
|
||||
"hint: (e.g., 'git pull ...') before pushing again.\n",
|
||||
"\n",
|
||||
"hint: See the 'Note about fast-forwards' in 'git push --help' for details.\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git pull\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"remote: Enumerating objects: 5, done.\n",
|
||||
"\n",
|
||||
"remote: Counting objects: 100% (5/5), done.\n",
|
||||
"\n",
|
||||
"remote: Compressing objects: 100% (2/2), done.\n",
|
||||
"\n",
|
||||
"remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0\n",
|
||||
"\n",
|
||||
"Unpacking objects: 100% (3/3), done.\n",
|
||||
"\n",
|
||||
"From https://github.com/red-quinoa/health-checks\n",
|
||||
"\n",
|
||||
" 92d659..a2dc118 master -> origin/master\n",
|
||||
"\n",
|
||||
"Auto-merging all\\_checks.py\n",
|
||||
"\n",
|
||||
"CONFLICT (content): Merge conflict in all\\_checks.py\n",
|
||||
"\n",
|
||||
"Automatic merge failed; fix conflicts and then commit the result.\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log \\--graph \\--oneline \\--all\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"\\* 03d23d0 Rename min\\_absolute to min\\_gb, use parameter names\n",
|
||||
"\n",
|
||||
"| \\* 42dc118 (origin/master, origin/HEAD) reorder conditional to match parameter order\n",
|
||||
"\n",
|
||||
"|/ \n",
|
||||
"\n",
|
||||
"| \\* 4d99c56 (origin/experimental, experimental) Empty check\\_load function\n",
|
||||
"\n",
|
||||
"|/ \n",
|
||||
"\n",
|
||||
"\\* 922d659 Add disk full check to all\\_checks.py\n",
|
||||
"\n",
|
||||
"\\* b62dc2e Add initial files for the checks\n",
|
||||
"\n",
|
||||
"\\* 807cb50 Add one more line to README.md\n",
|
||||
"\n",
|
||||
"\\* 3d9f86c Initial commit\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log \\-p origin/master\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"commit a2dc1181e5cccf36fec30d6eeefbe569a13883de (origin/master, origin/HEAD)\n",
|
||||
"\n",
|
||||
"Author: Blue Kale <bluekale@example.com>\n",
|
||||
"\n",
|
||||
"Date: Mon Jan 6 14:52:23 2020 -0800\n",
|
||||
"\n",
|
||||
" Reorder conditional to match parameter order\n",
|
||||
"\n",
|
||||
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"index e46cdae..6dda356 100755\n",
|
||||
"\n",
|
||||
"\\--- a/all\\_checks.py\n",
|
||||
"\n",
|
||||
"+++ b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"@@ -15,7 +15,7 @@ def check\\_disk\\_full(disk, min\\_absolute, min\\_percent):\n",
|
||||
"\n",
|
||||
" percent\\_free = 100 \\* du.free / du.total\n",
|
||||
"\n",
|
||||
" # Calculate how many free gigabytes\n",
|
||||
"\n",
|
||||
" gigabytes\\_free = du.free / 2\\*\\*30\n",
|
||||
"\n",
|
||||
"\\- if percent\\_free < min\\_percent or gigabytes\\_free < min\\_absolute:\n",
|
||||
"\n",
|
||||
"+ if gigabytes\\_free < min\\_absolute or percent\\_free < min\\_percent:\n",
|
||||
"\n",
|
||||
" return True\n",
|
||||
"\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"commit 922d65950b5325109525a24b71d8df8a46412d04 (HEAD -> master, origin/master, origin/HEAD)\n",
|
||||
"\n",
|
||||
"Author: Blue Kale <bluekale@example.com>\n",
|
||||
"\n",
|
||||
"Date: Mon Jan 6 14:42:44 2020 -0800\n",
|
||||
"\n",
|
||||
" Add disk full check to all\\_checks.py\n",
|
||||
"\n",
|
||||
"diff –git a/all\\_checks.py b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"atom all\\_checks.py\n",
|
||||
"\n",
|
||||
"#!/usr/binenv python3\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"\n",
|
||||
"def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
|
||||
"\n",
|
||||
" \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
|
||||
"\n",
|
||||
" du = shutil.disk\\_usage(disk)\n",
|
||||
"\n",
|
||||
" # Calculate the percentage of free space\n",
|
||||
"\n",
|
||||
" percent\\_free = 100 \\* du.free / du.total\n",
|
||||
"\n",
|
||||
" # Calculate how many free gigabytes\n",
|
||||
"\n",
|
||||
" gigabytes\\_free = du.free / 2\\*\\*30\n",
|
||||
"\n",
|
||||
"<<<<<<< HEAD\n",
|
||||
"\n",
|
||||
" if percent\\_free < min\\_percent or gigabytes\\_free < min\\_gb:\n",
|
||||
"\n",
|
||||
"\\=======\n",
|
||||
"\n",
|
||||
" if gigabytes\\_free < min\\_absolute or percent\\_free < min\\_percent:\n",
|
||||
"\n",
|
||||
"\\>>>>>>> a2dc1181e5cccf36fec30d6eeefbe569a13883de\n",
|
||||
"\n",
|
||||
" return True\n",
|
||||
"\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"(...)\n",
|
||||
"\n",
|
||||
"def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
|
||||
"\n",
|
||||
" \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
|
||||
"\n",
|
||||
" du = shutil.disk\\_usage(disk)\n",
|
||||
"\n",
|
||||
" # Calculate the percentage of free space\n",
|
||||
"\n",
|
||||
" percent\\_free = 100 \\* du.free / du.total\n",
|
||||
"\n",
|
||||
" # Calculate how many free gigabytes\n",
|
||||
"\n",
|
||||
" gigabytes\\_free = du.free / 2\\*\\*30\n",
|
||||
"\n",
|
||||
" if gigabytes\\_free < min\\_gb or percent\\_free < min\\_percent:\n",
|
||||
"\n",
|
||||
" return True\n",
|
||||
"\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git add all\\_checks.py \n",
|
||||
"\n",
|
||||
"git commit\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"Merge branch 'master' of https://github.com/redquinoa/health-checks\n",
|
||||
"\n",
|
||||
"Fixed check\\_disk\\_usage conditional to use the new order and new variable name.\n",
|
||||
"\n",
|
||||
"\\# Conflicts:\n",
|
||||
"\n",
|
||||
"\\# all\\_checks.py\n",
|
||||
"\n",
|
||||
"\\#\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git push\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"Enumerating objects: 10, done.\n",
|
||||
"\n",
|
||||
"Counting objects: 100% (10/10), done.\n",
|
||||
"\n",
|
||||
"Delta compression using up to 2 threads\n",
|
||||
"\n",
|
||||
"Compressing objects: 100% (6/6), done.\n",
|
||||
"\n",
|
||||
"Writing objects: 100% (6/6), 877 bytes | 877.00 KiB/s, done.\n",
|
||||
"\n",
|
||||
"Total 6 (delta 2), reused 0 (delta 0)\n",
|
||||
"\n",
|
||||
"remote: Resolving deltas: 100% (2/2), completed with 1 local object.\n",
|
||||
"\n",
|
||||
"To https://github.com/redquinoa/health-checks.git\n",
|
||||
"\n",
|
||||
" a2dc118..58351ff master -> master\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log \\--graph \\--oneline\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"\\* 58351ff (Head -> master, origin/master, origin/HEAD) Merge branch ‘master’ of https://github.com/redquinoa/health-checks.git\n",
|
||||
"\n",
|
||||
"|\\\\\n",
|
||||
"\n",
|
||||
"| \\* 42dc118 (origin/master, origin/HEAD) reorder conditional to match parameter order\n",
|
||||
"\n",
|
||||
"\\* | 03d23d0 Rename min\\_absolute to min\\_gb, use parameter names\n",
|
||||
"\n",
|
||||
"|/ \n",
|
||||
"\n",
|
||||
"| \\* 4d99c56 (origin/experimental, experimental) Empty check\\_load function\n",
|
||||
"\n",
|
||||
"|/ \n",
|
||||
"\n",
|
||||
"\\* 922d659 Add disk full check to all\\_checks.py\n",
|
||||
"\n",
|
||||
"\\* b62dc2e Add initial files for the checks\n",
|
||||
"\n",
|
||||
"\\* 807cb50 Add one more line to README.md\n",
|
||||
"\n",
|
||||
"\\* 3d9f86c Initial commit"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user