# Cryptography

## About

**Cryptography** is the science of securing information by transforming it into an unreadable format. It involves various techniques and algorithms designed to protect data confidentiality, integrity, authenticity, and non-repudiation. Cryptography ensures that sensitive information can be stored and transmitted securely, preventing unauthorized access and tampering. Cryptography includes a wide range of practices, algorithms, and protocols beyond just encryption and decryption.

{% hint style="success" %}
**What are cryptographic algorithms and cryptographic protocols ?**

A cryptographic algorithm is a mathematical procedure that is used to encrypt or decrypt data. For eg. Symmetric-key encryption algorithms, Asymmetric-key encryption algorithms, Hash functions.

A cryptographic protocol is a set of rules that define how cryptographic algorithms are used to achieve a specific security goal. For eg. Transport Layer Security (TLS), Secure Shell (SSH), Internet Protocol Security (IPSec).
{% endhint %}

## **Types of Cryptographic Algorithms**

### **Symmetric Key Cryptography**:

* Uses a single key for both encryption and decryption.
* Faster and more efficient but poses challenges in key distribution and management.
* Common algorithms: AES (Advanced Encryption Standard), DES (Data Encryption Standard), 3DES (Triple DES).

### **Asymmetric Key Cryptography**:

* Uses a pair of keys: a public key for encryption and a private key for decryption.
* Enhances security and simplifies key management.
* Common algorithms: RSA (Rivest-Shamir-Adleman), ECC (Elliptic Curve Cryptography).

### **Hash Functions**:

* Converts input data into a fixed-size string of characters, which is typically a digest that is unique to each unique input.
* Used for data integrity verification.
* Common algorithms: SHA (Secure Hash Algorithm), MD5 (Message Digest Algorithm 5).

### **Digital Signatures**:

* A method to verify the authenticity and integrity of a message, software, or digital document.
* Uses asymmetric cryptography.
* Common algorithms: RSA, DSA (Digital Signature Algorithm).

## **Goals of Cryptography**

### **Confidentiality**:

* Ensures that information is accessible only to those authorized to access it.
* Achieved through encryption.

### **Integrity**:

* Ensures that the information has not been altered in an unauthorized manner.
* Achieved through hashing and digital signatures.

### **Authentication**:

* Confirms the identity of the parties involved in communication.
* Achieved through digital certificates and public key infrastructure (PKI).

### **Non-repudiation**:

* Ensures that a party cannot deny the authenticity of their signature on a document or a message they sent.
* Achieved through digital signatures.

## **Applications of Cryptography**

1. **Secure Communication**:
   * Encrypting email, instant messages, and video calls to ensure that only intended recipients can read the content.
   * Protocols like TLS (Transport Layer Security) and SSL (Secure Sockets Layer) secure web communications.
2. **Data Protection**:
   * Encrypting data at rest, such as files stored on a hard drive or in cloud storage, to prevent unauthorized access.
   * Tools like BitLocker and FileVault provide full-disk encryption.
3. **Authentication and Access Control**:
   * Using cryptographic methods for user authentication in systems and applications.
   * Password hashing, multi-factor authentication, and digital certificates are commonly used.
4. **Digital Signatures and Certificates**:
   * Ensuring the authenticity and integrity of digital documents and software.
   * Widely used in software distribution, legal documents, and secure transactions.
5. **Financial Transactions**:
   * Securing online banking and payment systems to protect financial data.
   * Standards like PCI DSS mandate the use of encryption to protect cardholder data.
6. **Blockchain and Cryptocurrencies**:
   * Cryptographic techniques underpin blockchain technology and cryptocurrencies like Bitcoin and Ethereum.
   * Ensures secure transactions and decentralized consensus.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/spring/concepts-set-3/cryptography.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
