Skip to content

Instantly share code, notes, and snippets.

@SeLub
Created December 20, 2025 08:13
Show Gist options
  • Select an option

  • Save SeLub/9ce7bb488bd3fc41744142b3f2ecf756 to your computer and use it in GitHub Desktop.

Select an option

Save SeLub/9ce7bb488bd3fc41744142b3f2ecf756 to your computer and use it in GitHub Desktop.

Cryptography Functions and Parameters:

Cryptography is the practice of securing information by transforming it into a secret code that can only be decoded by authorized parties using specific cryptographic algorithms and keys. The primary objectives of cryptography are confidentiality, integrity, and authenticity. Below, we outline some common cryptographic functions along with their parameters:

1. Symmetric Encryption (AES - Advanced Encryption Standard)

Purpose: Ensures confidential communication between two parties by encrypting data using a single key. Parameters:

  • Key Size: Determines the strength of the encryption algorithm, typically measured in bits (e.g., 128, 256). Larger keys provide more security but reduce efficiency.
  • Mode of Operation: Defines how the data is processed within the block cipher (e.g., CBC, ECB, GCM). Common modes include Cipher Block Chaining (CBC) and Galois/Counter Mode (GCM), which offer better security than Electronic Codebook (ECB).
  • Padding Scheme: Ensures that plaintext blocks are a fixed size by adding extra bits to the end of the data. Examples include PKCS#5 or PKCS#7 padding, where the last block is padded with bytes indicating how many bytes need to be added to reach full length.

2. Asymmetric Encryption (RSA - Rivest–Shamir–Adleman)

Purpose: Provides secure communication between parties that do not share a secret key by using two keys: one public and one private. Parameters:

  • Key Size: The length of the RSA modulus, which determines the security level (e.g., 1024, 2048 bits). Larger keys generally provide more robust security against attacks but are computationally more expensive.
  • Exponent (Public Key): Typically uses a fixed value (65537) or custom values that comply with the requirements of RSA encryption. Exponents significantly smaller than this can lead to security risks known as "small exponent attacks."
  • Modulus (Private Key): The product of two large prime numbers, which is unique for each key pair and determines its strength against factorization attacks.

3. Hash Functions (SHA-256)

Purpose: Generate a fixed-size representation of the original data called a hash or message digest, used to ensure data integrity and authenticity without revealing the original content. Parameters:

  • Block Size: The size of the data blocks processed by the algorithm, which influences its performance and security properties. SHA-256 uses 512-bit blocks.
  • Output Size: The length of the hash value generated by the function (e.g., 256 bits for SHA-256). Larger outputs provide better collision resistance but are computationally more expensive to forge a message with a matching hash.

4. Digital Signatures

Purpose: Use asymmetric encryption to sign messages or documents, verifying the authenticity and integrity of the sender without revealing their private key. Parameters:

  • Hash Algorithm: The cryptographic hash function used to create the digital signature (e.g., SHA-256). This ensures that even if the message content changes slightly, its hash will be different, invalidating the previous signature.
  • Private Key: Used to sign data and prove authenticity.
  • Public Key: Used to verify signatures against the original data to ensure integrity and authenticity.

5. Random Number Generation (PRNG - Pseudo-Random Number Generator)

Purpose: Generate sequences of numbers that pass statistical tests for randomness, used as keys or salts in cryptographic algorithms. Parameters:

  • Seed: The initial value from which the sequence is generated; can be a fixed seed for reproducibility or dynamically updated for unpredictability.
  • Algorithm: Defines how to transform the seed into a pseudo-random sequence (e.g., Linear Congruential Generator, Mersenne Twister).

These cryptographic functions and their parameters are fundamental in ensuring secure data transmission across networks, protecting sensitive information from unauthorized access, and verifying the integrity of digital communications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment