Habr•October 9, 2026•🇷🇺Translated from Russian

Hash Functions Part 1: Core Properties, Security Requirements and Practical Applications

Hash Functions. Part 1: Fundamentals

Hash function is a function that accepts data of arbitrary length and produces a fixed-length output called a hash or digest. In practice, three core security properties must hold: preimage resistance, second-preimage resistance, and collision resistance. In addition, a good hash function exhibits the avalanche effect: the smallest change in input produces an unrecognizable change in output.

What is a Hash Function?

Preimage resistance means it is computationally infeasible to recover the original input from the digest. Second-preimage resistance means that, given an input and its digest, finding a different input that yields the same digest is practically impossible. Collision resistance means finding any two distinct inputs that produce the same digest is infeasible; neither input is fixed in advance.

Methods for Ensuring Hash Function Security

The theoretical properties have practical limits. Input data must possess sufficient entropy and length; otherwise an attacker can precompute hashes for all possible values and reverse the digest. The output size is equally critical. A minimum digest length of 256 bits is now considered mandatory because it delivers 128 bits of security against collision attacks. A 128-bit digest suffices only for the first two properties, since modern hardware cannot exhaust 2^128 possibilities.

The birthday paradox illustrates why 256 bits are required for collision resistance. The question “How many people must be in a room for a 50 percent chance that at least two share a birthday?” yields the answer 23. Mathematically, when sampling from a space of size 2^N, a collision is expected after roughly 2^(N/2) attempts. Therefore a 256-bit digest is needed to obtain 128-bit collision security. Because of insufficient collision resistance, MD5 and SHA-1 are considered broken.

Hash Functions in Practice

Hashing can be performed directly from the command line with OpenSSL:

echo -n "some words" | openssl dgst -sha256

Any supported algorithm may replace sha256, and a file path may be supplied instead of a string.

Hash functions enable commitment schemes: a party hashes secret data, publishes the digest, and later reveals the original value for verification. The function simultaneously hides the secret and binds the committer to the original data. They also protect web subresource integrity. When loading scripts or stylesheets from a CDN, the integrity attribute allows the browser to verify that the received file matches the expected digest:

  • <link rel="stylesheet" href="https://my-provider.com" integrity="sha256-HASH_OF_STYLE" crossorigin="anonymous">
  • <script src="https://my-provider.com" integrity="sha256-HASH_OF_SCRIPT" crossorigin="anonymous"></script>

The most widespread use is password storage with memory-hard functions such as Argon2 and bcrypt. Only the digest is stored; when a user supplies a password it is hashed and compared with the stored value. Because the digest itself must be transmitted securely, a hash function alone does not provide integrity; it must be used within a properly designed protocol.

This concludes Part 1. The next installment will examine the internal structure of SHA-2 and SHA-3, their respective strengths and weaknesses, and the appropriate use of XOF functions.

Related articles

Habr•Other

How to Prepare Your Website for Data Center Outages: Business Resilience Checklist

Following strikes on Yandex data centers, many businesses discovered that their sites and all backups were stored in a single location, leading to complete outages. The article provides a detailed checklist to mitigate such risks by separating critical components across different providers. Key recommendations include moving DNS to an independent provider, lowering TTL values, maintaining a live mirror site on separate hosting, and isolating corporate email. Additional steps cover local backups, monitoring, access management, and CDN usage. The guidance differentiates between virtual hosting, VPS or dedicated servers, and website builders like Tilda, while emphasizing compliance with Russian data localization laws such as 152-FZ.

Securitylab•Other

How to Properly Compare CDNs: TTFB, p95 Latency, Caching, DDoS Protection and True Pricing

Selecting a CDN based solely on the number of points of presence is as unreliable as choosing a car by dashboard buttons. Networks with dozens of global PoPs may underperform for audiences concentrated in Novosibirsk or Yekaterinburg, while smaller regional providers often deliver superior peering with Russian operators. The article evaluates CDNVideo, EdgeCenter, Curator, NGENIX and Yandex Cloud CDN across verifiable features, network design, caching behavior, security controls, operations and commercial models. Performance data is separated because marketing claims cannot substitute for independent measurements from services such as CDNMON. Emphasis is placed on p95 metrics, cache hit ratios, origin shielding, raw logs and API limits rather than marketing scores. The analysis shows that no single universal ranking exists; optimal choice depends on traffic profile, audience geography, security requirements and operational workflows.

Habr•Other

Innostage Lab Benchmarks PT NGFW 1.10.3 Performance in Eight Load Scenarios

Innostage researchers conducted extensive performance testing of PT NGFW version 1.10.3, the certified release at the time of trials. The evaluation covered TCP connection setup rates, concurrent session capacity, and throughput on a custom EMIX traffic profile with varying security modules enabled. Tests used Cisco TRex generators and a high-rule-count policy of 100,000 entries to simulate realistic enterprise conditions. Results showed the device sustaining 700,000 CPS and 6.4 million concurrent connections, matching or approaching vendor claims under HA-cluster configuration. Throughput remained above 27 Gbps even with IPS, application control, antivirus, NAT, URL filtering, and logging active. The report highlights differences in test methodology compared with vendor figures, including packet sizes and clustering setup.

Habr•Other

Java Card Tutorial: Implementing Supplementary Security Domain to Limit ISD Privileges

A detailed technical guide demonstrates how to create a Supplementary Security Domain (SSD) on Java Card platforms to isolate applet management from the Issuer Security Domain (ISD). The approach prevents full card compromise if ISD keys are exposed by restricting SSD privileges to specific functions such as accepting extradition only from the ISD. Using the FunGP library and SCP02 protocol, the tutorial walks through installation, personalization with encrypted keys, and extradition of applets under the new domain. GlobalPlatform specifications including GP CS v2.3 and GP CIC v2.0 are followed for install parameters, privileges, and STORE DATA commands. After personalization the SSD reaches the PERSONALIZED lifecycle state, allowing secure delegation of applet control while the ISD retains overall card management rights. The method eliminates the need for custom operating systems and provides a standards-compliant way to enforce least-privilege access on smart cards.