Makindo Medical Notes"One small step for man, one large step for Makindo" |
|
---|---|
Download all this content in the Apps now Android App and Apple iPhone/Pad App | |
MEDICAL DISCLAIMER: The contents are under continuing development and improvements and despite all efforts may contain errors of omission or fact. This is not to be used for the assessment, diagnosis, or management of patients. It should not be regarded as medical advice by healthcare workers or laypeople. It is for educational purposes only. Please adhere to your local protocols. Use the BNF for drug information. If you are unwell please seek urgent healthcare advice. If you do not accept this then please do not use the website. Makindo Ltd. |
Cryptography is the practice and study of techniques for securing communication and data from adversaries. It ensures the confidentiality, integrity, authenticity, and non-repudiation of information. Cryptography is fundamental to modern computer security, underpinning many technologies such as secure communications, digital signatures, and data encryption.
from cryptography.fernet import Fernet # Generate a key key = Fernet.generate_key() cipher = Fernet(key) # Encrypt data plaintext = b"Secret message" ciphertext = cipher.encrypt(plaintext) print(f"Ciphertext: {ciphertext}") # Decrypt data decrypted_text = cipher.decrypt(ciphertext) print(f"Decrypted text: {decrypted_text.decode()}")
from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives import serialization, hashes from cryptography.hazmat.primitives.asymmetric import padding # Generate RSA keys private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048) public_key = private_key.public_key() # Encrypt data plaintext = b"Secret message" ciphertext = public_key.encrypt( plaintext, padding.OAEP( mgf=padding.MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None ) ) print(f"Ciphertext: {ciphertext}") # Decrypt data decrypted_text = private_key.decrypt( ciphertext, padding.OAEP( mgf=padding.MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None ) ) print(f"Decrypted text: {decrypted_text.decode()}")
import hashlib # Hash data data = b"Important data" hash_object = hashlib.sha256(data) hash_digest = hash_object.hexdigest() print(f"SHA-256 Hash: {hash_digest}")
Cryptography is essential for securing communication and data in modern computing. Key concepts include plaintext, ciphertext, encryption, decryption, and keys. Cryptography is divided into symmetric and asymmetric key cryptography, with hash functions also playing a critical role. Applications of cryptography include secure communications, digital signatures, authentication, data integrity, and non-repudiation. Challenges in cryptography involve key management, cryptographic attacks, quantum computing threats, and performance overhead. The future of cryptography will focus on post-quantum cryptography and blockchain technologies.