# Research on Encryption and Decryption [TOC] >**Islamic University Of Gaza** >**Faculty Of Engineering** >**Computer And Network Security (ECOM 5401)** >This document has been created to assist in developing the required research for the Network Security course. The link will be submitted to **Professor Mohammed Makki** for evaluation. **Group Members:** **Ahmad F.Battah 120192642** **Islam Aljammaly 120203027** **Bahaa Elghazali 120190904** ## PART A : Research topics ### 1\. Introduction to Encryption and Decryption Encryption refers to the process of converting data, referred to as plaintext, into an unreadable form, known as ciphertext. This process ensures that unauthorized individuals cannot access the data, and only authorized users with the correct decryption key can revert the ciphertext to its original form. Decryption is the reverse process, converting ciphertext back to plaintext. Encryption plays a crucial role in ensuring secure communication, protecting sensitive information, and safeguarding privacy. It is widely used in online banking, e-commerce, secure messaging, and healthcare systems, ensuring that data remains confidential and tamper-proof during transmission. ![650a9786c6c59_encryption_vs_decryption_07](https://hackmd.io/_uploads/rkSV_eQ6R.jpg) ___ ### 2\. Types of Encryption Encryption techniques can be classified into several types based on their usage, algorithms, and structure. Here’s an advanced look at some of the prominent types of encryption, emphasizing their strengths, weaknesses, and applications. #### 1. Symmetric Encryption - Overview: Both the sender and receiver use the same secret key for encryption and decryption. - Key Algorithms: - AES (Advanced Encryption Standard): AES-128, AES-192, and AES-256 are widely used due to their high efficiency and security. AES-256 is particularly resistant to brute-force attacks and is the standard for government and military encryption. - DES (Data Encryption Standard): DES, now considered obsolete due to its short key length (56-bit), was replaced by AES. Triple DES (3DES) extends DES but is still less secure than AES. - Strengths: Fast and efficient for encrypting large volumes of data. Used in situations like database encryption and file system encryption. - Weaknesses: Key distribution and management are challenges, especially across distributed systems, as the same key must be securely shared between parties. - Application: VPNs, TLS for web security, encrypted disk storage. #### 2. Asymmetric Encryption - Overview: Utilizes a pair of keys – a public key for encryption and a private key for decryption. It’s also known as public-key encryption. - Key Algorithms: - RSA: One of the most common algorithms, RSA is used extensively in secure data transmission, like SSL/TLS for website encryption. Its security relies on the computational difficulty of factoring large integers. - Elliptic Curve Cryptography (ECC): ECC provides comparable security to RSA with shorter key lengths, making it faster and more efficient in environments with limited computational resources. - Strengths: Solves the key distribution problem in symmetric encryption by allowing secure exchange of keys over unsecured channels. - Weaknesses: Significantly slower than symmetric encryption, especially with larger data sets. Used primarily for key exchange and digital signatures rather than bulk data encryption. - Application: Digital certificates, secure messaging, blockchain. #### 3. Hybrid Encryption - Overview: Combines symmetric and asymmetric encryption to leverage the strengths of both. The symmetric key is encrypted using asymmetric encryption, and the data is encrypted using symmetric encryption. - Application: Most secure protocols, such as SSL/TLS, use hybrid encryption. Symmetric encryption is used to encrypt the data, while the asymmetric method ensures secure exchange of the symmetric key. - Strengths: Offers both security (from asymmetric) and efficiency (from symmetric). - Weaknesses: Still relies on secure public-key infrastructure (PKI) for key management. #### 4. Homomorphic Encryption - Overview: A highly specialized form of encryption that allows computations to be performed on encrypted data without decrypting it. The results of these computations, when decrypted, match the results of operations performed on the plaintext data. - Key Algorithms: - Fully Homomorphic Encryption (FHE): Supports arbitrary computations on encrypted data. - Partially Homomorphic Encryption: Allows either addition or multiplication operations but not both. - Strengths: Enables privacy-preserving computation, especially useful in cloud computing and AI/ML where sensitive data needs to remain encrypted during processing. - Weaknesses: Computationally expensive and inefficient for large-scale operations due to its heavy overhead. - Application: Privacy-preserving machine learning, encrypted cloud services. #### 5. Quantum-Resistant Encryption - Overview: As quantum computing advances, many traditional encryption methods (such as RSA and ECC) will become vulnerable. Quantum-resistant encryption algorithms are being developed to withstand attacks from quantum computers. - Key Algorithms: - Lattice-Based Cryptography: A promising candidate for post-quantum cryptography, relying on the hardness of lattice problems. - Multivariate Polynomial Cryptography: Another approach that promises security against quantum attacks but is less mature than lattice-based techniques. - Strengths: Prepares systems for future quantum threats. - Weaknesses: Still under development and can be less efficient than current classical encryption. - Application: Future-proofing cryptographic systems, especially for long-term data storage. #### 6. End-to-End Encryption (E2EE) - Overview: Ensures that data is encrypted at the point of origin and only decrypted at the final destination. Even service providers or intermediaries do not have access to the encryption keys. - Strengths: High privacy and security, widely adopted in messaging apps like WhatsApp and Signal. - Weaknesses: Can complicate compliance with legal or regulatory requirements for data access. - Application: Secure messaging, data transmissions, collaborative tools like Google Docs. ![using-public-and-private-key-for-encryption-Asymmetric-encryption-classes-usually-use-two](https://hackmd.io/_uploads/H1rOYgQpA.png) --- ### 3\. History of Encryption The history of encryption is a fascinating journey that spans thousands of years, reflecting the evolution of technology, mathematics, and the need for secure communication. Here’s a comprehensive overview of how encryption has developed over time: **Ancient Encryption** #### 1. Classical Ciphers Caesar Cipher (circa 58 BC): Named after Julius Caesar, this is one of the earliest known ciphers. It is a substitution cipher where each letter in the plaintext is shifted a fixed number of places down or up the alphabet. For example, with a shift of 3, A becomes D. Atbash Cipher: An ancient Hebrew cipher where letters of the alphabet are mapped to their reverse (A ↔ Z, B ↔ Y). It was used in the Bible and other ancient texts. #### 2. Scytale Cipher (circa 5th century BC) - Overview: Used by the Spartans, the scytale cipher involved wrapping a strip of parchment around a cylindrical object. The message was written on the parchment, and when unwrapped, the letters appeared scrambled. Only a matching cylinder could decrypt the message. **Medieval Encryption** #### 3. Vigenère Cipher (circa 1553) - Overview: Developed by Blaise de Vigenère, this cipher uses a keyword to shift letters of the plaintext. It is a polyalphabetic cipher, meaning it uses multiple substitution alphabets to encrypt the message. It was considered unbreakable for centuries. #### 4. Enigma Machine (1920s-1940s) - Overview: The German Enigma machine was a complex mechanical device used during World War II. It used a series of rotating wheels and plugboard settings to encrypt messages. Its security was eventually broken by Allied cryptanalysts, including Alan Turing, which significantly impacted the outcome of the war. **Modern Encryption** #### 5. Development of Modern Cryptography 1940s-1970s: The advent of computers brought about new methods for encryption and decryption. The development of public-key cryptography in the 1970s marked a significant shift in how encryption was approached. #### 6. Public-Key Cryptography (1970s) - Diffie-Hellman Key Exchange (1976): Introduced by Whitfield Diffie and Martin Hellman, this protocol allows two parties to securely exchange cryptographic keys over an insecure channel without having shared a secret beforehand. - RSA Algorithm (1977): Developed by Ron Rivest, Adi Shamir, and Leonard Adleman, RSA is one of the first public-key cryptosystems. It relies on the difficulty of factoring large prime numbers and is used for secure data transmission and digital signatures. **Modern Cryptographic Standards** #### 7. Symmetric Key Algorithms Data Encryption Standard (DES, 1977): Adopted by the U.S. National Institute of Standards and Technology (NIST) as a federal standard for encrypting non-classified information. DES uses a 56-bit key and was widely used until it was found to be vulnerable to brute-force attacks. Advanced Encryption Standard (AES, 2001): AES replaced DES and is widely used today. It supports key sizes of 128, 192, and 256 bits and provides strong encryption with efficient performance. #### 8. Elliptic Curve Cryptography (ECC) - Overview: ECC provides similar security to RSA but with shorter key lengths, making it more efficient in terms of speed and computational resources. It is increasingly used in modern systems, including mobile devices and secure communications. #### 9. Post-Quantum Cryptography - Emerging Threats: The development of quantum computers poses a threat to many classical encryption methods. Post-quantum cryptography is an area of research focused on developing encryption methods that are resistant to quantum attacks. This includes lattice-based cryptography and hash-based signatures. **Recent Advances** #### 10. Homomorphic Encryption - Overview: Allows computations to be performed on encrypted data without decrypting it. This is particularly useful for privacy-preserving computations in cloud computing and secure data analysis. #### 11. Blockchain and Cryptocurrencies - Overview: Blockchain technology relies heavily on cryptographic principles. Cryptocurrencies like Bitcoin use hashing algorithms (e.g., SHA-256) and digital signatures (e.g., ECDSA) to secure transactions and ensure the integrity of the blockchain. Encryption has evolved from simple substitution ciphers in ancient times to complex algorithms that form the backbone of modern digital security. From the Caesar cipher to AES and beyond, the field of encryption continues to advance as new challenges and technologies emerge, including quantum computing and privacy-preserving computation. This evolution reflects the growing importance of data security in our increasingly digital world. ![large_0](https://hackmd.io/_uploads/BJrcjg7a0.jpg) ____ ### 4\. Fundamental Principles of Encryption The fundamental principles of encryption are foundational concepts that ensure the secure transformation of data into a format that is unreadable to unauthorized parties. Understanding these principles is crucial for designing and implementing effective encryption systems. Here’s a detailed overview: #### 1. Confidentiality - Overview: The primary goal of encryption is to ensure that data remains confidential. Only authorized parties should be able to access the plaintext data. - How It Works: Data is transformed into ciphertext using an encryption algorithm and a key. Only those with the correct decryption key can revert the ciphertext to its original plaintext form. - Example: In email encryption, the message content is converted into ciphertext so that only the intended recipient with the decryption key can read it. #### 2. Integrity - Overview: Integrity ensures that data has not been altered during transmission or storage. Encryption helps in detecting unauthorized changes to the data. - How It Works: Integrity is often maintained through cryptographic hash functions and message authentication codes (MACs). Hash functions produce a unique hash value for the original data, and any alteration changes this hash value. - Example: Digital signatures are used in software distribution to verify that the software has not been tampered with and is from a legitimate source. #### 3. Authentication - Overview: Authentication verifies the identity of the parties involved in communication. It ensures that the entities involved in the transaction are who they claim to be. - How It Works: Authentication is achieved through mechanisms such as digital signatures and certificates, which use cryptographic keys to verify identities. - Example: When accessing a secure website, digital certificates issued by Certificate Authorities (CAs) authenticate the website’s identity. #### 4. Non-Repudiation - Overview: Non-repudiation ensures that once a transaction or communication has been made, the sender cannot deny having sent it. It provides proof of the origin and receipt of the communication. - How It Works: Non-repudiation is typically achieved using digital signatures. When a document is signed with a private key, the sender cannot later deny their involvement. - Example: In financial transactions, digital signatures are used to ensure that transactions are verifiable and that the sender cannot later dispute the transaction. #### 5. Key Management - Overview: Effective key management is crucial for encryption systems. It involves the generation, distribution, storage, and disposal of cryptographic keys. - How It Works: Keys must be managed securely to prevent unauthorized access. Key management systems (KMS) and protocols are used to handle keys throughout their lifecycle. - Example: In a corporate environment, a KMS ensures that encryption keys used for encrypting sensitive data are securely stored and regularly updated. #### 6. Algorithm Strength - Overview: The strength of an encryption algorithm determines its resistance to attacks. Strong algorithms are designed to be computationally infeasible to break. - How It Works: The strength of an algorithm is influenced by key length, algorithm complexity, and resistance to known cryptographic attacks. - Example: AES-256 is considered strong because it provides robust encryption due to its long key length and resistance to brute-force attacks. #### 7. Entropy and Randomness - Overview: Entropy refers to the randomness or unpredictability of the data used in encryption. High entropy ensures that encrypted data appears random and is not susceptible to patterns that could be exploited. - How It Works: Cryptographic keys and initialization vectors (IVs) should be generated with high entropy to prevent predictability. - Example: Secure key generation involves using high-quality random number generators to ensure that keys are unpredictable and unique. #### 8. Modes of Operation - Overview: Modes of operation define how encryption algorithms process data blocks and handle various types of data. - Common Modes: - ECB (Electronic Codebook): Simplest mode where each block is encrypted independently. It’s not recommended for use because it can reveal patterns in plaintext. - CBC (Cipher Block Chaining): Each block of plaintext is XORed with the previous ciphertext block before being encrypted, which provides better security than ECB. - GCM (Galois/Counter Mode): Provides both encryption and authentication, ensuring data integrity and confidentiality. - Example: AES-GCM is commonly used in secure communication protocols to ensure data confidentiality and integrity. #### 9. Key Exchange Protocols - Overview: Key exchange protocols allow two parties to securely share encryption keys over an insecure channel. - Common Protocols: - Diffie-Hellman Key Exchange: Allows two parties to generate a shared secret key without having shared a key beforehand. - Elliptic Curve Diffie-Hellman (ECDH): A variant of Diffie-Hellman that uses elliptic curves for improved efficiency. - Example: HTTPS uses Diffie-Hellman or ECDH to securely exchange keys between a web browser and a server. #### 10. Cryptographic Hash Functions - Overview: Hash functions produce a fixed-size hash value from input data. They are used for data integrity and authentication. - Characteristics: Hash functions should be deterministic, fast to compute, infeasible to reverse, and resistant to collisions (two different inputs should not produce the same hash). - Example: SHA-256 is commonly used in digital signatures and data integrity checks to produce a unique hash value for a given input. The fundamental principles of encryption— confidentiality, integrity, authentication, non- repudiation, key management, algorithm strength, entropy, modes of operation, key exchange protocols, and hash functions—form the backbone of secure communications and data protection. These principles ensure that data remains secure from unauthorized access, alteration, and fraud, while maintaining the integrity of digital interactions. ___ ### 5\. Modern Encryption Algorithms **Advanced Encryption Standard (AES)** AES is the standard for symmetric encryption today. It operates on fixed block sizes of 128 bits and offers key lengths of 128, 192, and 256 bits. AES is known for its efficiency and security, making it ideal for securing government and industry data. **RSA (Rivest-Shamir-Adleman)** RSA is one of the first public-key cryptosystems, and it remains in widespread use today. RSA’s security relies on the difficulty of factoring large prime numbers. It is commonly used for secure data transmission, particularly in establishing secure key exchanges. **Blowfish** Blowfish is a symmetric encryption algorithm known for its speed and flexibility. It was designed as a general-purpose encryption algorithm and is widely used in applications such as securing files and encrypting passwords. **Elliptic Curve Cryptography (ECC)** ECC is a type of public-key encryption that offers the same level of security as RSA but with much smaller key sizes. It is particularly useful for mobile devices and low-power computing environments due to its efficiency. ![computer-science-information-technology-32-g006](https://hackmd.io/_uploads/Sk75Te7a0.gif) ### 6\. Encryption Protocols Encryption protocols are standardized methods used to secure communication and data through encryption. These protocols define how encryption is applied, ensuring that data is protected during transmission or storage. Here’s an overview of some widely used encryption protocols, their features, and typical applications: #### 1. Transport Layer Security (TLS) / Secure Sockets Layer (SSL) - Overview: TLS and its predecessor, SSL, are protocols designed to secure data transmitted over networks, primarily the internet. - How It Works: TLS/SSL uses a combination of asymmetric encryption (for key exchange), symmetric encryption (for data encryption), and cryptographic hash functions (for data integrity). - Versions: - SSL: Older versions (SSL 2.0, SSL 3.0) are considered insecure and have been deprecated. - TLS: The successor to SSL, with TLS 1.2 and TLS 1.3 being widely used. TLS 1.3 provides improved security and performance compared to TLS 1.2. - Application: Used to secure HTTPS connections in web browsing, email communication, and other internet-based services. #### 2. Secure/Multipurpose Internet Mail Extensions (S/MIME) - Overview: S/MIME is a protocol for securing email communication using encryption and digital signatures. - How It Works: S/MIME uses asymmetric encryption (public key infrastructure) to encrypt email contents and provide digital signatures for authentication and integrity. - Key Components: - Certificates: Used for encrypting and signing emails. - Encryption Algorithms: Typically uses RSA for encryption and AES for symmetric encryption of email contents. - Application: Widely used in corporate and secure email systems to ensure confidentiality and authenticity. #### 3. Pretty Good Privacy (PGP) / GNU Privacy Guard (GPG) - Overview: PGP is an encryption standard used for securing email and files. GPG is an open-source implementation of PGP. - How It Works: Uses a combination of asymmetric encryption (for key exchange) and symmetric encryption (for data encryption). PGP also includes hashing for integrity. - Key Components: - Public and Private Keys: For encrypting and decrypting messages. - Web of Trust: PGP uses a decentralized model to verify key authenticity. - Application: Used for encrypting email, files, and communication over the internet. #### 4. Internet Protocol Security (IPsec) - Overview: IPsec is a suite of protocols designed to secure IP communications by authenticating and encrypting each IP packet in a communication session. - How It Works: IPsec can operate in two modes: - Transport Mode: Encrypts only the payload of the IP packet, leaving the header intact. - Tunnel Mode: Encrypts the entire IP packet, including the header, and encapsulates it in a new IP packet. - Key Components: - Authentication Header (AH): Provides packet-level integrity and authentication. - Encapsulating Security Payload (ESP): Provides confidentiality, along with optional integrity and authentication. - Application: Commonly used in VPNs (Virtual Private Networks) to secure communications over public networks. #### 5. Secure Hypertext Transfer Protocol (HTTPS) - Overview: HTTPS is an extension of HTTP that uses TLS/SSL to secure data transmitted between web browsers and servers. - How It Works: HTTPS ensures that web communications are encrypted, protecting data from eavesdropping and tampering. - Key Components: - TLS/SSL Encryption: Used to encrypt data in transit. - Certificates: Used to authenticate the identity of the server and establish a secure connection. - Application: Used for secure web browsing, online transactions, and accessing sensitive information on websites. #### 6. Wireless Security Protocols (WEP, WPA, WPA2, WPA3) - Overview: These protocols are used to secure wireless networks. - How It Works: - WEP (Wired Equivalent Privacy): An older protocol with known vulnerabilities, providing weak security. - WPA (Wi-Fi Protected Access): An improvement over WEP, using TKIP (Temporal Key Integrity Protocol) for enhanced security. - WPA2: Uses AES encryption and provides robust security features. - WPA3: The latest standard, offering improved encryption and protection against brute-force attacks. - Application: Used to secure Wi-Fi networks and protect wireless communications from unauthorized access. #### 7. Kerberos - Overview: Kerberos is a network authentication protocol designed to provide strong authentication for client-server applications using secret-key cryptography. - How It Works: Kerberos uses a trusted third party (the Key Distribution Center, KDC) to authenticate users and issue time-stamped tickets for secure communication. - Key Components: - Authentication Server (AS): Issues Ticket-Granting Tickets (TGT). - Ticket-Granting Server (TGS): Issues service tickets for accessing specific services. - Application: Used in enterprise environments to provide secure authentication for accessing network services. #### 8. Simple Network Management Protocol Version 3 (SNMPv3) - Overview: SNMPv3 is used for managing network devices and includes features for securing communication. - How It Works: SNMPv3 adds security features such as authentication, encryption, and message integrity to the standard SNMP protocol. - Key Components: - User-Based Security Model (USM): Provides authentication and encryption. - View-Based Access Control Model (VACM): Manages access control and permissions. - Application: Used for secure management of network devices like routers, switches, and servers. #### 9. Internet Key Exchange (IKE) - Overview: IKE is used to set up a secure communication channel between two parties by negotiating and establishing encryption keys and security parameters. - How It Works: IKE is part of the IPsec suite and operates in two phases: - Phase 1: Establishes a secure channel (IKE SA) using Diffie-Hellman key exchange. - Phase 2: Negotiates IPsec SAs to protect data traffic. - Application: Used in VPNs to establish secure connections between network endpoints. Encryption protocols are essential for securing data in various contexts, from web browsing and email to network communications and wireless security. By applying different encryption techniques and standards, these protocols ensure data confidentiality, integrity, and authentication, adapting to the specific needs and security requirements of each application. ![tls-ssl-handshake](https://hackmd.io/_uploads/H1XEAx7TC.png) ___ ### 7\. Data Encryption in Network Data encryption in a network context involves securing data as it travels across or is stored within a network. This is crucial for protecting sensitive information from unauthorized access, tampering, and interception. Here’s a detailed look at the different aspects and methods of data encryption in networks: #### 1. Encryption in Data Transmission **a. End-to-End Encryption (E2EE)** - Overview: Ensures that data is encrypted on the sender’s device and only decrypted on the recipient’s device. This prevents intermediaries, including service providers, from accessing the data. - How It Works: Data is encrypted before it is sent over the network and remains encrypted until it reaches the recipient. Only the intended recipient can decrypt the data with the appropriate key. - Examples: Messaging apps like WhatsApp and Signal use end-to-end encryption to secure messages. **b. Transport Layer Security (TLS)** - Overview: Secures data transmitted over networks, primarily the internet, by encrypting the communication channel between clients and servers. - How It Works: TLS establishes a secure connection using asymmetric encryption (for key exchange) and symmetric encryption (for data encryption). It also provides data integrity through hashing. - Versions: TLS 1.2 and TLS 1.3 are widely used versions. TLS 1.3 provides enhanced security and performance improvements over TLS 1.2. - Application: Used in HTTPS to secure web traffic, email communication, and other internet-based services. **c. Secure Sockets Layer (SSL)** - Overview: The predecessor to TLS, SSL is used to encrypt data in transit. SSL 2.0 and 3.0 are outdated and insecure, and TLS has largely replaced them. - Application: Historical use in HTTPS and other secure communications, but now mostly superseded by TLS. #### 2. Encryption in Data Storage **a. Disk Encryption** - Overview: Protects data stored on disks or other storage devices by encrypting the entire disk or specific volumes. - How It Works: Full-disk encryption (FDE) encrypts all data on the disk, while file-level encryption targets individual files or directories. - Examples: BitLocker (Windows), FileVault (macOS), and LUKS (Linux) are common disk encryption -solutions. **b. Database Encryption** - Overview: Encrypts sensitive data stored in databases to protect it from unauthorized access. - How It Works: Data can be encrypted at the column level (encrypting specific fields) or the whole database. It often includes key management practices to handle encryption keys securely. - Examples: Oracle Advanced Security, Microsoft SQL Server Transparent Data Encryption (TDE), and MySQL’s built-in encryption features. #### 3. Network-Level Encryption **a. Internet Protocol Security (IPsec)** - Overview: A suite of protocols designed to secure IP communications by authenticating and encrypting each IP packet. - How It Works: IPsec operates in two modes: - Transport Mode: Encrypts only the data payload of each IP packet. - Tunnel Mode: Encrypts the entire IP packet, including the header, and encapsulates it in a new packet. - Application: Commonly used in Virtual Private Networks (VPNs) to secure communications over public networks. **b. Virtual Private Network (VPN)** - Overview: A VPN creates a secure, encrypted connection over a less secure network, such as the internet. - How It Works: VPNs use encryption protocols (e.g., IPsec, SSL/TLS) to protect data in transit between the client and the VPN server. - Types: - Site-to-Site VPN: Connects entire networks securely over the internet. - Remote Access VPN: Allows individual users to connect securely to a remote network. - Examples: OpenVPN, IPsec VPN, and SSL VPN. #### 4. Encryption in Wireless Networks **a. Wireless Encryption Protocols** - Overview: Secures wireless communications between devices and access points in Wi-Fi networks. - Types: - WEP (Wired Equivalent Privacy): An older protocol with known vulnerabilities. No longer recommended. - WPA (Wi-Fi Protected Access): Improved security over WEP using TKIP (Temporal Key Integrity Protocol). - WPA2: Uses AES encryption, providing robust security features. - WPA3: The latest standard, offering enhanced security, protection against brute-force attacks, and improved encryption. - Application: Used in securing Wi-Fi networks in homes, offices, and public spaces. #### 5. Encryption in Network Protocols **a. Simple Network Management Protocol Version 3 (SNMPv3)** - Overview: Secures network management communication by adding authentication, encryption, and message integrity. - How It Works: Uses User-Based Security Model (USM) for encryption and authentication, and View-Based Access Control Model (VACM) for access control. - Application: Used to manage and monitor network devices securely. **b. Secure/Multipurpose Internet Mail Extensions (S/MIME)** - Overview: Encrypts email communication to ensure confidentiality and integrity. - How It Works: Uses public-key cryptography to encrypt email contents and digital signatures to verify the sender’s identity. - Application: Used for secure email communications in business and government. #### 6. Key Management **a. Public Key Infrastructure (PKI)** - Overview: A framework for managing digital keys and certificates used in encryption and authentication. - How It Works: PKI uses a combination of hardware, software, policies, and procedures to issue, manage, and validate digital certificates and public/private keys. - Components: - Certificate Authorities (CAs): Issue and verify digital certificates. - Registration Authorities (RAs): Assist in the identification and authentication of users before issuing certificates. - Key Management Systems (KMS): Manage encryption keys throughout their lifecycle. - Application: Used in securing communications, digital signatures, and encryption across various systems. Data encryption in networks is essential for protecting information as it is transmitted or stored. Key methods include end-to-end encryption for communications, TLS for secure data transmission, IPsec for network-level security, and encryption protocols for wireless and network communications. Effective encryption also involves robust key management practices and the use of modern standards and protocols to ensure data confidentiality, integrity, and authenticity. ![VPN_Glossary_2](https://hackmd.io/_uploads/HJdjCxQTC.png) --- ### 8\. Quantum Encryption Quantum encryption, also known as quantum cryptography, leverages the principles of quantum mechanics to secure data and communications in ways that classical cryptography cannot. Here’s an overview of quantum encryption, including its principles, technologies, and potential impacts: **Principles of Quantum Encryption** #### 1. Quantum Key Distribution (QKD) - Overview: QKD is a technique used to securely distribute cryptographic keys between two parties. It uses the principles of quantum mechanics to detect eavesdropping and ensure secure key exchange. - Principles: - Heisenberg Uncertainty Principle: The act of measuring a quantum system disturbs it, which can reveal the presence of an eavesdropper. - Quantum Superposition: Quantum bits (qubits) can exist in multiple states simultaneously, which allows for complex key distribution schemes. - Protocols: - BB84 Protocol: One of the first and most widely used QKD protocols, developed by Charles Bennett and Gilles Brassard. It uses polarized photons to distribute a secret key. - E91 Protocol: Developed by Artur Ekert, it uses entangled photon pairs to establish a secure key. #### 2. Quantum Entanglement - Overview: Entanglement is a quantum phenomenon where pairs of particles become correlated in such a way that the state of one particle instantly influences the state of the other, regardless of distance. - Application in Cryptography: Entanglement can be used to create correlated quantum states between parties, providing a basis for secure communication and key distribution. **Technologies and Implementation** #### 1. Quantum Key Distribution Systems - Overview: QKD systems use quantum properties to securely distribute encryption keys. They require specialized hardware to generate, transmit, and detect quantum states. - Components: - Photon Sources: Generate quantum states (e.g., polarized photons). - Quantum Detectors: Measure the quantum states and detect potential eavesdropping. - Quantum Repeaters: Extend the range of QKD by overcoming the limitations of direct photon transmission over long distances. #### 2. Quantum Random Number Generators (QRNG) - Overview: QRNGs generate random numbers using quantum processes, providing high-quality randomness for cryptographic applications. - How It Works: QRNGs exploit quantum phenomena, such as the decay of radioactive isotopes or the behavior of single photons, to produce truly random numbers. - Application: Used for generating cryptographic keys, ensuring unpredictability and security. #### 3. Quantum Communication Networks - Overview: Quantum communication networks aim to implement quantum encryption on a larger scale, integrating QKD and other quantum technologies into existing communication infrastructures. - Examples: - Quantum Internet: A proposed network that uses quantum entanglement and QKD to enable secure communication and quantum information transfer. - Quantum Satellite Networks: Satellites equipped with quantum communication technology can facilitate global-scale QKD and quantum networking. **Potential Impacts and Challenges** #### 1. Enhanced Security - Overview: Quantum encryption offers unprecedented security by detecting eavesdropping and ensuring that any attempt to intercept or tamper with the communication can be detected. - Impact: It could lead to virtually unbreakable encryption, significantly improving the security of sensitive information and communications. #### 2. Post-Quantum Cryptography - Overview: While quantum encryption provides new security methods, quantum computers pose a threat to classical cryptographic algorithms. Post-quantum cryptography aims to develop encryption methods resistant to quantum attacks. - Impact: Research in post-quantum cryptography is essential to ensure that classical cryptographic systems remain secure in the future. #### 3. Cost and Complexity - Overview: Quantum encryption technology is currently expensive and complex to implement, requiring specialized hardware and infrastructure. - Challenges: Widespread adoption will require advancements in technology, cost reduction, and integration with existing systems. #### 4. Regulatory and Standardization Issues - Overview: The development and deployment of quantum encryption technologies will require new regulations and standards to ensure interoperability and security. - Challenges: Establishing global standards and regulations for quantum encryption will be crucial for its successful implementation. Quantum encryption represents a groundbreaking advancement in securing data and communications by leveraging the principles of quantum mechanics. Quantum Key Distribution (QKD) and quantum entanglement are key technologies in this field, offering enhanced security and the potential for a quantum internet. While quantum encryption promises significant benefits, it also faces challenges related to cost, complexity, and the need for regulatory frameworks. As the technology matures, it could revolutionize data security and address future threats posed by quantum computing. ![Schematic-of-a-general-quantum-key-distribution-QKD-protocol](https://hackmd.io/_uploads/ry_QJWX60.png) ____ ### 9\. Challenges and Limitations in Encryption Encryption is a crucial aspect of modern cybersecurity, but it comes with various challenges and limitations. Here’s an overview of the key issues associated with encryption: #### 1. Key Management **a. Complexity** - Overview: Managing encryption keys involves generating, storing, distributing, and rotating keys securely. This process can be complex and error-prone. - Challenges: - Key Storage: Ensuring that keys are stored securely and protected from unauthorized access. - Key Distribution: Safely distributing keys to authorized parties without interception. - Key Rotation: Regularly updating keys to mitigate the risk of key compromise. **b. Scalability** - Overview: As organizations grow, the number of keys and their management becomes more challenging. - Challenges: - Large Number of Keys: Managing multiple keys across various systems and applications. - Automated Key Management: Implementing automated systems to handle key management at scale. #### 2. Performance Impact **a. Processing Overhead** - Overview: Encryption and decryption processes consume computational resources, which can impact system performance. - Challenges: - Latency: Increased latency due to encryption and decryption operations. - Resource Usage: Higher CPU and memory usage, which may affect the performance of other applications. **b. Scalability Issues** - Overview: As the volume of data increases, encryption processes may become a bottleneck. - Challenges: - Handling Large Data Sets: Ensuring that encryption does not degrade performance for large-scale applications. #### 3. Cryptographic Vulnerabilities **a. Algorithm Weaknesses** - Overview: Some encryption algorithms may have inherent weaknesses or vulnerabilities that can be exploited. - Challenges: - Obsolescence: Algorithms that were once secure may become outdated as new attacks are discovered. - Algorithm Selection: Choosing and implementing strong, up-to-date algorithms to avoid vulnerabilities. **b. Implementation Flaws** - Overview: Incorrect implementation of encryption algorithms can introduce vulnerabilities. - Challenges: - Coding Errors: Bugs or errors in encryption code that can compromise security. - Side-Channel Attacks: Attacks that exploit information leaked during encryption or decryption processes (e.g., timing attacks). #### 4. Regulatory and Compliance Issues **a. Legal Constraints** - Overview: Regulations and laws governing encryption vary by country and region, affecting how encryption can be used and implemented. - Challenges: - Export Controls: Restrictions on exporting encryption technology to certain countries. - Compliance Requirements: Meeting various regulatory requirements, such as GDPR, HIPAA, and others. **b. Data Sovereignty** - Overview: The location of encrypted data and the jurisdiction of the data can impact compliance and legal considerations. - Challenges: - Cross-Border Data Transfer: Ensuring compliance with data protection laws when transferring encrypted data across borders. #### 5. User Education and Adoption **a. Complexity for End Users** - Overview: Encryption technologies can be complex for end users, leading to potential misuse or failure to implement. - Challenges: - User Training: Educating users about proper encryption practices and the importance of key management. - Usability: Designing user-friendly encryption solutions that do not compromise security. **b. Resistance to Adoption** - Overview: Some organizations or individuals may resist adopting encryption due to perceived complexity or inconvenience. - Challenges: - Cost vs. Benefit: Balancing the cost of encryption implementation with the perceived benefits. #### 6. Quantum Computing Threats **a. Future Threats** - Overview: Quantum computing has the potential to break current encryption algorithms that rely on mathematical problems that quantum computers can solve efficiently. - Challenges: - Post-Quantum Cryptography: Developing and adopting cryptographic algorithms that are resistant to quantum attacks. **b. Transition Challenges** - Overview: Transitioning to quantum-resistant encryption methods will be a complex and gradual process. - Challenges: - Migration: Updating existing systems and protocols to support new quantum-resistant algorithms. #### 7. Data Integrity and Availability **a. Data Integrity** - Overview: Ensuring that encrypted data remains intact and unaltered is crucial for maintaining data integrity. - Challenges: - Tampering Detection: Implementing mechanisms to detect and prevent unauthorized modifications. **b. Data Availability** - Overview: Ensuring that encrypted data remains accessible to authorized users while protected from unauthorized access. - Challenges: - Backup and Recovery: Managing encrypted backups and ensuring that data can be recovered without compromising security. Encryption is vital for protecting data and communications but it comes with several challenges and limitations. Key management, performance impact, cryptographic vulnerabilities, regulatory compliance, user education and emerging threats like quantum computing all pose significant issues. Addressing these challenges requires a combination of robust technology, effective practices and ongoing research to ensure that encryption continues to provide strong security in an evolving landscape. ____ ### 10\. Encryption and Decryption in Practical Applications Encryption and decryption are crucial in various practical applications to protect sensitive information and ensure privacy. Here’s an overview of how they are applied in key areas: **a. Data Transmission (Networking and Communications)** - Example: HTTPS (Hypertext Transfer Protocol Secure). - Encryption: HTTPS uses SSL/TLS to encrypt data transmitted between a client (such as a browser) and a server, ensuring that sensitive information like login credentials and payment data is not intercepted. - Decryption: The server and client both decrypt the data to process it securely. **b. Secure Storage (Data at Rest)** - Example: Database encryption. - Encryption: Sensitive data in databases, such as credit card details, health records, and passwords, are encrypted using algorithms like AES (Advanced Encryption Standard) to prevent unauthorized access. - Decryption: Authorized users and systems decrypt the data when needed. **c. Email Security** - Example: End-to-End Encryption (E2EE) in emails. - Encryption: Services like ProtonMail or PGP (Pretty Good Privacy) encrypt emails so that only the sender and recipient can read them. - Decryption: The recipient decrypts the email using their private key. **d. File Sharing and Cloud Storage** - Example: Google Drive or Dropbox encryption. - Encryption: Files uploaded to cloud services are encrypted to ensure they cannot be read by unauthorized parties, including the cloud provider. - Decryption: Users with the correct keys or credentials can decrypt and access their files. **e. Disk Encryption** - Example: BitLocker (Windows), FileVault (macOS). - Encryption: Full disk encryption protects all data stored on a hard drive by encrypting it. If a device is stolen or lost, the data remains secure. - Decryption: Only authorized users with the correct password or key can decrypt the data and use the device. **f. Authentication and Password Protection** - Example: Hashing and encryption for passwords. - Encryption: Passwords are hashed (and sometimes encrypted) when stored to protect them from being exposed in case of a data breach. - Decryption: In a secure system, passwords are not decrypted but hashed and compared with stored values. **g. Mobile Applications** - Example: Encrypted messaging apps like WhatsApp, Signal. - Encryption: Messages are encrypted end-to-end, meaning they are scrambled into an unreadable format while in transit. - Decryption: The messages are decrypted only on the recipient’s device. **h. Digital Payments** - Example: Payment systems like Apple Pay, Google Pay, or online banking. - Encryption: Sensitive financial data is encrypted during transactions using protocols like EMV (Europay, Mastercard, and Visa) and tokenization, ensuring secure payments. - Decryption: Banks and payment gateways decrypt the data securely to authorize and process payments. **i. Blockchain and Cryptocurrencies** - Example: Bitcoin, Ethereum. - Encryption: Public and private key encryption is used to secure transactions in blockchain systems, ensuring that only the rightful owner of cryptocurrency can authorize transactions. - Decryption: Private keys are used to decrypt and authorize cryptocurrency transfers. **j. Two-Factor Authentication (2FA)** - Example: Authenticator apps, SMS-based authentication. - Encryption: OTPs (One-Time Passwords) generated by 2FA apps are often encrypted during transmission. - Decryption: The server decrypts the OTP and verifies it against the user’s input for authentication. Encryption and decryption mechanisms in these applications ensure confidentiality, integrity, and authenticity of data, safeguarding user privacy and protecting against various cyber threats. ____ ### 11\. Future and Emerging Trends in Encryption As encryption evolves to address the growing complexity of digital security, several emerging trends are shaping the future of encryption technology. These trends aim to enhance the robustness, efficiency, and applicability of encryption methods in the face of new technological challenges, particularly quantum computing and the increasing sophistication of cyberattacks. #### 1. Post-Quantum Cryptography - Challenge: Quantum computers have the potential to break current encryption algorithms, such as RSA and ECC (Elliptic Curve Cryptography), due to their immense processing power. - Trend: Post-quantum cryptography (PQC) focuses on developing algorithms that are resistant to quantum attacks. Leading candidates like lattice-based cryptography, multivariate cryptography, and hash-based cryptography are being explored to safeguard data in a quantum world. - Current Status: NIST (National Institute of Standards and Technology) is working on standardizing post-quantum encryption algorithms, with the first draft expected in the near future. #### 2. Homomorphic Encryption - Definition: Homomorphic encryption allows computation on encrypted data without needing to decrypt it, preserving data privacy during processing. - Applications: It’s particularly useful in scenarios like cloud computing, where users can perform operations on encrypted data stored in the cloud without exposing the raw data to the service provider. - Advances: Fully homomorphic encryption (FHE) is being optimized to reduce the computational overhead, making it more practical for widespread use in industries like healthcare, finance, and AI-driven analytics. #### 3. Zero-Knowledge Proofs (ZKP) - Definition: ZKPs enable one party to prove to another that they know a value without revealing the value itself. - Applications: ZKPs are gaining traction in blockchain, privacy-preserving applications, and identity verification. For example, ZCash (a cryptocurrency) uses ZKP to verify transactions without exposing the sender, recipient, or amount. - Future: ZKPs are expected to enhance privacy in digital identity systems, decentralized finance (DeFi), and secure voting systems, where privacy and trust are critical. #### 4. Lightweight Encryption for IoT - Challenge: The rise of IoT (Internet of Things) devices, which often have limited processing power and battery life, requires efficient encryption algorithms that balance security and performance. - Trend: Lightweight encryption algorithms, such as SIMON and SPECK, are being developed to secure data on constrained devices. These algorithms are optimized for speed and low power consumption, ensuring that IoT networks are secure without draining device resources. - Impact: Securing smart homes, connected cars, industrial IoT, and healthcare wearables with lightweight encryption will be crucial as the number of IoT devices continues to skyrocket. #### 5. Blockchain-Based Encryption - Use Case: Decentralized encryption schemes using blockchain can offer a tamper-proof, distributed method for managing and verifying encryption keys. This can help mitigate central points of failure in traditional key management systems. - Trend: Blockchain can ensure data integrity and secure decentralized storage of encryption keys. For instance, decentralized storage platforms like Filecoin or Sia use blockchain to secure encrypted data fragments across a distributed network. - Future Potential: Blockchain-based encryption methods can revolutionize data storage, access control, and sharing, especially in decentralized applications (dApps). ![7-Figure1-1](https://hackmd.io/_uploads/Hy0VGbXTR.png) ___ ### 12\. Case Studies and Practical Examples **The Apple vs. FBI Encryption Debate** In 2016, Apple refused to comply with an FBI request to unlock a terrorist’s iPhone, citing the potential for creating a backdoor that could be exploited. This case highlights the tension between privacy and security in the age of encryption. **WhatsApp – End-to-End Encryption for Messaging** - Overview: In 2016, WhatsApp implemented end-to-end encryption for its 2 billion users. This means that only the sender and the recipient can read the messages, and even WhatsApp cannot access them. - Encryption Used: WhatsApp uses Signal Protocol for encryption, which combines the Double Ratchet algorithm, prekeys, and curve25519 for secure key exchanges. - Impact: This encryption ensures that user communication remains private, even if someone intercepts the data in transit or gains unauthorized access to WhatsApp's servers. - Challenge: While encryption secures conversations, it also raises concerns for law enforcement agencies that argue it hinders criminal investigations by making it difficult to access potentially crucial data. **SSL/TLS in E-Commerce** Online shopping platforms use SSL/TLS to encrypt transactions, ensuring that customers’ payment information remains confidential during transmission. ___ ### 13\. Encryption in Artificial Intelligence and Machine Learning (Advanced Topic) #### 1. Homomorphic Encryption in ML - Overview: Homomorphic encryption allows computations to be performed on encrypted data without the need to decrypt it. This ensures that sensitive data remains secure even during the processing stage. - Applications: - Secure Model Training: In scenarios like healthcare and finance, sensitive datasets can be encrypted, and machine learning models can be trained directly on this encrypted data. This helps prevent data leakage while allowing models to learn from it. - Federated Learning: Homomorphic encryption is useful in federated learning, where multiple organizations or devices collaborate to train a shared machine learning model without revealing their private data. Encryption ensures that only the aggregated results are shared, not the raw data. - Example: A healthcare provider may encrypt patient data, and a model trained on this encrypted data can predict disease risks without revealing patient identities or sensitive health information. #### 2. Differential Privacy - Overview: Differential privacy ensures that individual data points within a dataset are protected from identification, even when combined with external data. This is critical when AI systems analyze datasets containing personal or sensitive information. - Applications: - Data Sharing for AI Development: By adding noise to datasets, AI models can still learn patterns from the data without exposing individual records. This technique is used by companies like Apple and Google to analyze large datasets while maintaining user privacy. - Privacy-Preserving Machine Learning: Organizations can build machine learning models that generate useful insights while ensuring that sensitive individual data points cannot be reverse-engineered from the outputs. - Example: Google uses differential privacy in services like Google Maps to collect location data in a way that prevents individual users from being identified. #### 3. Secure Multi-Party Computation (MPC) - Overview: MPC allows multiple parties to jointly compute a function over their encrypted inputs without revealing the inputs to one another. This is particularly valuable when training AI models on combined datasets from different sources. - Applications: - Collaborative ML Model Training: Multiple organizations can securely collaborate on training AI models without sharing raw data. For example, banks could jointly build fraud detection models without exposing proprietary customer data to competitors. - Privacy-Preserving Data Analytics: MPC can be used to perform encrypted data analytics, ensuring that sensitive information remains private even while performing complex analysis. - Example: In a financial setting, different banks could use MPC to jointly analyze transaction data to detect fraud patterns without exposing individual customer data to each other. ![Homomorphic-encryption-1](https://hackmd.io/_uploads/ByAE4-7a0.png) ____ ### 14\. Distributed Encryption (Advanced Topic) Distributed encryption refers to techniques and systems where encryption is applied across distributed systems or networks to ensure data security and privacy. This approach is often used to protect data in environments where data is stored and processed across multiple locations, such as in cloud computing, distributed databases, and decentralized networks. Here are key aspects and practical examples of distributed encryption: #### 1. Encryption in Distributed Databases - Overview: Distributed databases often span multiple servers or data centers, making data encryption across these nodes crucial to maintain security. - Approach: - End-to-End Encryption: Data is encrypted on the client side before being sent to the database, and only decrypted when retrieved by authorized clients. - Database-Level Encryption: Data is encrypted while stored in the database. This encryption can be implemented at the file system level, database management system (DBMS) level, or through transparent data encryption (TDE). - Example: MongoDB supports encrypted storage engines that provide data-at-rest encryption, ensuring that data is encrypted on disk and decrypted only when accessed by authorized users. #### 2. Cloud Storage Encryption - Overview: Cloud storage services often utilize distributed encryption to protect data stored in the cloud. Encryption ensures data privacy and compliance with regulations. - Approach: - Client-Side Encryption: Data is encrypted on the client side before being uploaded to the cloud. The cloud provider never has access to the plaintext data. - Server-Side Encryption: Data is encrypted by the cloud service provider before storing it and decrypted only for authorized users. - Example: Google Cloud Storage and Amazon S3 offer server-side encryption with options to manage encryption keys through their respective key management services. #### 3. Distributed Ledger Technologies (DLT) and Blockchain - Overview: Distributed ledger technologies, including blockchain, use encryption to secure transactions and ensure the integrity of the ledger. - Approach: - Cryptographic Hash Functions: Each block in a blockchain is hashed, and the hash is used to link blocks together, ensuring data integrity. - Public-Key Cryptography: Used for securing transactions and providing digital signatures. Only the holder of the private key can sign transactions, while others use the public key to verify the signature. - Example: Bitcoin and Ethereum use public-key cryptography and hash functions to secure transactions and maintain a tamper-proof record of all transactions. #### 4. Homomorphic Encryption for Distributed Computation - Overview: Homomorphic encryption allows computations to be performed on encrypted data without needing to decrypt it first, making it ideal for distributed systems where data needs to be processed securely. - Approach: - Privacy-Preserving Computations: Multiple parties can perform computations on encrypted data, such as in federated learning or collaborative data analysis, without exposing the data to each other. - Example: Microsoft SEAL is an open-source homomorphic encryption library that can be used to perform computations on encrypted data in distributed systems. ___ ### 15\. Cryptanalysis and Reverse Encryption (Advanced Topic) **What is Cryptanalysis?** Cryptanalysis is the process of breaking encryption algorithms by finding vulnerabilities. Attackers use techniques such as brute-force attacks, frequency analysis, and side-channel attacks to compromise encryption. **Reverse Encryption** Reverse encryption involves analyzing encrypted data to uncover the original plaintext without knowing the key. This process is often used in ethical hacking to test the robustness of encryption algorithms. ![GFG02](https://hackmd.io/_uploads/SyQdB-Qp0.png) ___ ### References and sources **1- National Institute of Standards and Technology (NIST)** Provides information on encryption standards and guidelines. **2- International Association for Cryptologic Research (IACR)** Contains a wide range of research papers and resources on cryptography. **3- Wikipedia** A comprehensive entry on cryptography, including encryption, decryption, and related topics. **4- "Applied Cryptography: Protocols, Algorithms, and Source Code in C"** Bruce Schneier Wiley, 2015. This book provides a comprehensive overview of cryptographic algorithms and protocols. **5- "Cryptography and Network Security: Principles and Practice"** William Stallings Pearson, 2017. A widely used textbook that covers both cryptographic techniques and network security principles. **5-** http://www.simonsingh.com/codebook.htm  The Code Book website. ___ ## PART B : Project ### Development of a simple web application that encrypts and decrypts messages using JavaScript. We will develop a simple web application designed to encrypt and decrypt messages using JavaScript. This single-page application will feature a user-friendly interface built with HTML, CSS, and JavaScript. Users will be able to input their messages and select a chosen encryption method from a predefined set of algorithms. The application will then encrypt or decrypt the input message accordingly, providing immediate feedback on the transformed text. This project will showcase the practical implementation of encryption techniques in a web environment, demonstrating how to secure and manage sensitive information effectively. ![1](https://hackmd.io/_uploads/ryVgTSrCA.png) ![2](https://hackmd.io/_uploads/HyWQ6rBR0.png) index.html ``` <!DOCTYPE html> <html > <head> <title >Security Project</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> <style> #app{ width: 100%; max-width: 100%; } #app p{ width: 100%; padding: 14px; background: rgb(90, 88, 88); color: white; text-align: center; font-family: sans-serif; font-size: 22px; } #app textarea{ width: 100%; border:2px solid rgb(138, 138, 138); outline: none; border-radius: 14px; min-height: 140px; } #app select{ width: 100%; padding: 14px; border-radius: 14px; margin-bottom: 14px; } </style> </head> <body dir="ltr"> <nav class="navbar navbar-light bg-light"> <h1 >Security Project</h1> </nav> <main id="app"> <p>Text</p> <select id="select"> <option style="text-align: center;" value="encode">Encryption</option> <option style="text-align: center;" value="decode">Decrypt</option> </select> <textarea id="text"></textarea> <p> Result </p> <textarea id="result"> </textarea> </main> <div class="card"> <div style="text-align: center;" class="card-header"> About Us </div> <div class="card-body" > <blockquote class="blockquote mb-0"> <p style="text-align: center;">A site to decrypt base-64 encrypted text, or encrypt it with base-64 encryption.</p> </blockquote> </div> </div> <script src="app.js"></script> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script> </body> </html> ``` app.js ``` // The btoa() method encodes a string in base-64. // ---------------------------------------------------------------------------- // This method uses the "A-Z", "a-z", "0-9", "+", "/" and "=" characters to encode the string. //------------------------------------------------------------------------------ // Tip: Use the atob() method to decode a base-64 encoded string. let textarea = document.getElementById("text"); let result = document.getElementById("result"); let select = document.getElementById("select"); textarea.addEventListener("input",()=>{ make_result(); }); select.addEventListener("change",()=>{ make_result(); }); function make_result(){ if(select.value == "decode"){ result.value = window.atob(textarea.value) ; }else{ result.value = window.btoa(textarea.value) ; } ```