Hash
Hash may refer to several distinct concepts across various fields:Hashish
Etymology and history
The term "hashish" derives from the Arabic word ḥašiš (حَشِيش), meaning "hay," "dry grass," or "dried herb," reflecting its original association with plant material.[1] This etymology entered European languages in the late 16th century, with the English word first recorded around 1598 as a reference to the psychoactive resin derived from cannabis.[1] The pronunciation in English is typically /həˈʃiːʃ/, preserving the Arabic phonetic structure.[1] The earliest attested historical reference to hashish appears in a polemical pamphlet published in Cairo in 1123 CE, where the Fatimid caliph al-Āmir bi-Aḥkām Allāh accused the Nizari Ismaili Muslims—later known in the West as the Assassins—of being "hashish-eaters" (ḥašišiyyīn), linking the substance to their reputed use for inducing trance-like states before missions.[2] This association, though likely propagandistic, marks the term's emergence in written records amid sectarian conflicts in the Islamic world. Hashish's origins trace back to Central Asia, where cannabis cultivation began millennia ago, before spreading southward to regions including modern-day Afghanistan and India by the early centuries CE through trade and migration routes.[3] In South Asia, particularly along the Himalayan foothills, indigenous Cannabis indica strains were harvested for resin, with hashish production documented in Indian texts by the 11th century.[4] From there, it extended westward to Afghanistan, becoming a staple in local traditions, and eventually to North Africa, including Morocco, where resin processing techniques evolved by the medieval period.[5] Hashish reached Europe in the 18th century via Orientalist scholarship and travel accounts, with the first scientific documentation provided by German botanist Johann Friedrich Gmelin in his 1777 work Allgemeine Geschichte der Pflanzengifte, describing its use in Eastern contexts for intoxicating effects.[6] Its medicinal application peaked in Europe and the United States from approximately 1880 to 1900, when it was prescribed for conditions such as pain, migraines, asthma, and insomnia, supported by over 100 scientific publications exploring its therapeutic potential.[7] This era of acceptance ended with increasing regulatory pressures, culminating in international prohibition under the 1961 United Nations Single Convention on Narcotic Drugs, which classified cannabis resin—including hashish—as a Schedule I substance subject to strict controls on production, trade, and non-medical use.[8]Production and composition
Hashish is primarily produced through mechanical separation of the resinous trichomes from the female cannabis plant, followed by compression into a solid form. Traditional mechanical techniques include dry sifting, where dried cannabis flowers are rubbed or beaten over fine silk or metal screens to collect the powdery kief—loose trichomes that are then pressed into blocks using heat and pressure. This method, common in regions like Morocco for producing kif varieties, yields a product with potency depending on the quality of the starting material and sieving fineness. Another mechanical approach is ice-water extraction, also known as bubble hash production, in which cannabis material is agitated in ice-cold water to detach trichomes, which are subsequently filtered through micron screens, dried, and pressed; this solventless process preserves the full spectrum of plant compounds but requires careful handling to avoid contamination.[9] Chemical extraction methods employ solvents to isolate cannabinoids and terpenes more efficiently, though they introduce potential residues if not properly purged. Butane hash oil (BHO), for instance, involves passing liquid butane through cannabis-packed tubes to dissolve resins, followed by evaporation of the solvent to yield a viscous concentrate that can be further processed into shatter, wax, or other forms; this technique allows for higher yields and potencies but poses safety risks due to the flammable nature of butane. Modern solvent extractions have enabled the production of highly concentrated hashish variants, contrasting with historical hand-rubbed charas from Afghanistan, where resin is manually collected by rubbing fresh plants.[9] Major production regions have historically included Afghanistan and Morocco. In Afghanistan, pre-2023 cultivation spanned 10,000–24,000 hectares, yielding 1,500–3,500 metric tons of resin annually around 2009 via hand-rubbing techniques for charas-style hash known for its dark, sticky texture and high resin content from indica-dominant strains; however, following the Taliban's nationwide ban on cannabis cultivation in March 2023, production has significantly declined.[10] Morocco remains a key supplier to Europe, with illicit production estimated at 700–800 metric tons of cannabis resin in 2023 across clandestine areas in the Rif Mountains, primarily using dry sifting for kif varieties that are compressed into blond or red hashes.[11] Morocco legalized medical and industrial cannabis under Law 13-21 in 2021, leading to a surge in legal production (nearly 4,200 tonnes in 2024), though illicit hashish output persists for export markets.[12] These regions have accounted for significant shares of global illicit production, though recent policy changes have shifted dynamics. The composition of hashish centers on compounds extracted from cannabis glandular trichomes, including primary cannabinoids such as Δ⁹-tetrahydrocannabinol (THC), cannabidiol (CBD), and cannabinol (CBN), alongside terpenes like myrcene and limonene that contribute to aroma and viscosity. THC levels vary widely by production method, strain, and region: confiscated samples in Europe averaged 3–15% THC in 2011, though modern extracts can exceed this due to selective breeding and advanced processing. For instance, high-potency Afghan varieties have reached up to 65% THC in premium black hash forms. CBD and CBN typically comprise smaller fractions (under 5% combined in most samples), while terpenes and waxes make up 20–50% of the mass, influencing texture and stability. Purity is higher in mechanical methods that avoid solvents, but contemporary hashish is generally more potent than historical forms, with THC concentrations doubling in some markets since the early 2000s due to improved cultivation and extraction.[13][14]Effects and uses
Hashish, a concentrated resin derived from the Cannabis sativa plant, primarily exerts its effects through delta-9-tetrahydrocannabinol (THC), the main psychoactive compound responsible for its pharmacological actions.[15] The psychoactive effects of hashish typically include euphoria, relaxation, and altered perception of time and sensory experiences.[16][15] These effects arise from THC's interaction with cannabinoid receptors in the brain, leading to a sense of well-being and heightened sensory awareness.[15] When smoked, onset occurs within approximately 5 to 15 minutes, with peak effects shortly thereafter, while ingestion delays onset to 30 to 60 minutes due to slower absorption through the digestive system.[17][18] Historically, in the 19th century, hashish and cannabis extracts were employed in Western medicine for pain relief and to treat insomnia, often as tinctures or patent medicines.[19][20] These applications leveraged the sedative and analgesic properties attributed to cannabinoids. In modern contexts, hashish is used recreationally for its euphoric and relaxing effects, while therapeutic applications focus on symptom management for conditions like chronic pain and nausea, though evidence remains mixed and primarily drawn from broader cannabis research.[21] Common consumption methods for hashish include smoking, often via pipes or joints to heat the resin directly; vaporizing, which heats it to release active compounds without combustion; and incorporation into edibles for oral ingestion.[22] Each method influences the intensity and duration of effects, with smoking and vaporizing providing faster onset compared to edibles. Compared to marijuana, which consists of dried flowers and leaves, hashish is a more concentrated form of resin with higher cannabinoid density, particularly THC levels that can exceed those in herbal cannabis by several fold.[23] This results in similar psychoactive effects—euphoria, relaxation, and altered perception—but often more intensified due to the elevated potency, potentially leading to stronger subjective experiences at equivalent doses.[24] In traditional cultural practices, hashish has been used in Middle Eastern rituals, notably among Sufi sects like the Qalandars in historical Iran, where it facilitated spiritual introspection and communal bonding.[25] In South Asia, cannabis resins akin to hashish (such as charas) hold religious significance in Hindu rituals, consumed during festivals to enhance devotion and meditation.[4]Legal status and cultural impact
Hashish, as a concentrated form of cannabis resin, is classified internationally under the 1961 United Nations Single Convention on Narcotic Drugs, where cannabis and its resin are listed in Schedule I, subjecting it to strict controls on production, trade, and use for non-medical purposes.[8] Until 2020, it was also included in Schedule IV, which reserved the most severe restrictions, but the Commission on Narcotic Drugs removed cannabis from this schedule following a review that acknowledged its medical potential while maintaining prohibitions on recreational use.[26] This framework has been ratified by over 180 countries, requiring signatories to limit hashish to medical and scientific applications and criminalize non-authorized activities. Recent developments include Germany's legalization of recreational cannabis in April 2024, allowing possession and home cultivation, alongside similar reforms in Luxembourg (2023) and Malta (2021).[27] Regionally, hashish remains illegal for recreational use in most countries, with possession, production, and distribution punishable by severe penalties, including imprisonment. However, variations exist: Canada legalized cannabis, including hashish products, for recreational and medical use nationwide on October 17, 2018, under the Cannabis Act, which regulates production, sale, and consumption through licensed frameworks.[28] In the United States, while federal law classifies cannabis—including hashish—as a Schedule I substance under the Controlled Substances Act, 24 states had legalized recreational cannabis by 2025, often encompassing concentrates like hashish, alongside broader medical access in 40 states.[29] These divergences have sparked tensions with international obligations, as some jurisdictions permit uses that challenge the UN convention's prohibitions. As of November 2025, federal rescheduling efforts to move cannabis to Schedule III remain ongoing but unresolved.[30] Culturally, hashish has been intertwined with countercultural movements, notably the 1960s hippie era, where it symbolized rebellion against societal norms and was embraced as a tool for spiritual exploration and communal bonding during events like Woodstock.[31] Earlier influences trace to the Beat Generation of the 1950s, whose writers, including Jack Kerouac and Allen Ginsberg, incorporated hashish experiences into literature that critiqued materialism and promoted altered consciousness, paving the way for broader psychedelic influences in music by artists like The Beatles and Bob Dylan.[32] This association extended to literature and art, fostering a legacy of hashish as a emblem of nonconformity and creative inspiration in Western counterculture.[33] Economically, hashish drives a significant black market, with Morocco remaining a primary producer, accounting for a substantial portion of global illicit supply through clandestine cultivation in the Rif Mountains, fueling exports primarily to Europe. In 2023, the European Union consumed approximately 1,013 tonnes of cannabis resin, with the illicit market valued at €7.7–12 billion annually.[11] These figures underscore the scale of illicit trade, though recent bans (e.g., Afghanistan 2023) and legalizations (e.g., Morocco 2021) have influenced supply chains and underground revenue. Modern trends reflect growing legalization debates, with hashish increasingly integrated into the regulated cannabis industry in permissive regions, where it is processed into edibles, oils, and other products amid calls for rescheduling to align with evidence of lower harm profiles compared to other substances.[34] By 2025, public support for cannabis reform, including hashish variants, reached about 90% in the U.S. for some form of legalization, influencing policy shifts toward decriminalization and economic opportunities in emerging markets.[35]The hash symbol
Names and origins
The symbol # is known by a variety of names across different regions and contexts, including the number sign, pound sign (especially in North America), hash, octothorpe, hashtag, sharp, square, and hex.[36] These appellations reflect its multifaceted roles in notation, measurement, and technology, with "pound sign" deriving from its historical association with weight and "number sign" from its use to denote numerals.[37] The origins of the # symbol trace back to the 14th century, when it evolved as a scribal abbreviation for the Latin phrase libra pondo (℔), referring to the Roman unit of weight equivalent to a pound.[38] Over time, the ligature of "l" and "b" from libra simplified into the crossed lines of the modern #, appearing in medieval European manuscripts for accounting and measurement purposes.[38] In typographic history, the symbol gained prominence with its inclusion on the keyboard of the Remington Standard typewriter around 1886, marking one of its earliest mechanical implementations.[39] It was later formalized in the American Standard Code for Information Interchange (ASCII) in 1963, where it was designated as one of the 95 printable characters to support data processing and communication standards.[40] The symbol's adoption in telephony occurred in 1968, when Bell Labs incorporated it on the bottom right of touch-tone keypads as a non-numeric function key to facilitate advanced signaling in their dual-tone multi-frequency system.[41] This placement expanded its utility beyond printing to interactive electronic interfaces.[41] The term "octothorpe" was coined in the 1960s by Bell Labs engineer Don Macpherson to describe the symbol during training sessions for the new touch-tone system; it combines the Greek prefix octo- (eight), referencing the symbol's eightfold radial points, with "thorpe," possibly a playful nod to athlete Jim Thorpe or an arbitrary suffix for memorability.[42] This neologism emerged among engineers as a humorous alternative to existing names and spread within technical communities.[43] In contemporary usage, the name "hashtag" gained widespread recognition in 2007 when it was repurposed on social media platforms like Twitter for categorizing content.[36]Uses in notation and writing
In North American English, particularly in the United States and Canada, the hash symbol (#) is widely used as a prefix to abbreviate "number" before a numeral, as in "#2 pencil" to denote a "number two pencil." This informal convention appears in everyday writing, product labeling, and technical specifications, where it replaces the spelled-out word for brevity.[44][45] The symbol also denotes units of weight in pounds when placed after a numeral, such as "5# bag" indicating a five-pound bag, a usage rooted in its historical ties to measurement abbreviations. This application is common in commercial contexts like packaging and retail but is distinctly North American.[46] In proofreading and manuscript editing, the # mark is inserted between letters or words to signal the insertion of a space, ensuring proper separation in typeset text; for example, "word#word" instructs the typesetter to add spacing. This standard symbol dates to traditional print production practices and remains in use among editors.[47] Although the proper musical sharp symbol is ♯, the hash # often substitutes in typed or informal notation to indicate a note raised by a semitone, such as C# for C-sharp; however, professional scores favor the distinct ♯ to avoid confusion with other meanings.[48] In literature and journalism, the # denotes sequence in headings and bulleted lists, as in "#1 tip" for the primary recommendation, and serves as a placeholder for numerical references, such as in outlines or indexes. Press releases commonly end with "###" centered to mark the conclusion of the main content. Outside North America, especially in non-English-speaking regions, this numbering role is rarer, with alternatives like "No." or "Nr." preferred.[44][49]Uses in technology
In telephony, the hash symbol serves as the "pound key" on touch-tone keypads, introduced by Bell Labs in 1968 as part of the dual-tone multi-frequency (DTMF) signaling system for interactive voice response (IVR) menus.[50] This key enables users to navigate automated systems by entering codes for options, such as selecting menu items or confirming inputs; for instance, in some U.S. states like Virginia, dialing #77 connects mobile users to highway emergency dispatch services.[51] In computing, the hash symbol denotes single-line comments in scripting languages, where everything following it on a line is ignored by the interpreter. For example, in Python, lines beginning with # are used for explanatory notes, as specified in the language's style guide.[52] Similarly, in Bash shell scripts, # initiates comments to document code without affecting execution. It also appears in programming contexts like LaTeX, where # acts as a parameter delimiter in macro definitions, allowing arguments to be passed and substituted within commands. On the web, the hash symbol identifies URL fragments, or anchor points, enabling direct navigation to specific sections of a page, as defined in the URI generic syntax standard.[53] For instance, appending #section to a URL jumps to the element with id="section" in HTML documents. Additionally, in web technologies like CSS, # prefixes hexadecimal color codes, such as #FF0000 for red, providing a compact notation for specifying colors in stylesheets.[54] The symbol has been part of the ASCII character set since its standardization in 1963, with code 35 (0x23).[55] In social media, the hash symbol prefixes hashtags for content categorization and discovery, a convention proposed by Chris Messina in a 2007 blog post to group Twitter messages by topic without native tagging features.[56] This practice, initially manual, was later natively supported by platforms like Twitter (now X), enabling trend tracking and searchability across posts.Hash marks
In sports
In sports, hash marks refer to short, perpendicular lines painted on playing fields or courts to assist officials, players, and coaches with precise measurements, positioning, and gameplay enforcement. These markings ensure consistent play by delineating key distances and boundaries, such as yardage intervals or player placement zones, thereby facilitating fair competition and accurate officiating across various athletic disciplines.[57][58] In American football, hash marks are prominent short lines, typically 24 inches long and spaced every five yards along the length of the field between the goal lines. They mark yardage intervals from the sidelines and define the inbounds area where the ball must be spotted for the start of each play, preventing setups too close to the boundary and allowing balanced offensive options to either side. This placement influences strategy, as the ball's position relative to the hashes affects kicking angles and running lanes. In the National Football League (NFL), these marks have been standardized at 18 feet 6 inches apart—70 feet 9 inches from each sideline—since 1972, a change implemented to widen the effective playing area, promote more dynamic offense, and align with goalpost positioning for field goals.[59][60] In soccer (association football), hash marks appear as optional one-yard lines drawn perpendicular to the goal line, located 11 yards from each corner flag and extending one yard beyond the goal line outside the field of play. Their primary role is to enforce the 10-yard minimum distance that opposing players must maintain from the ball during corner kicks, helping referees quickly verify compliance and maintain order during set pieces. These markings, while not mandatory under FIFA laws, are commonly used in professional and collegiate games to enhance precision in restarts.[61][62][63] Other sports employ similar hash marks for lane starts and player alignment. In track and field, small hash marks or scratch lines—often 0.05 meters wide and colored for visibility—mark starting positions in individual lanes for sprint and relay events, ensuring runners begin from accurate stagger points to compensate for curve distances and guiding relay handoffs. In basketball, hash marks on the court include sets parallel to the baseline near the free throw circle (13 feet from the baseline and 3 feet from lane lines, 6 inches long) to designate standing positions for non-shooters during free throws, as well as perpendicular marks near the baseline to outline the lower defensive box for foul restrictions. These features collectively support officials in enforcing rules and players in maintaining proper spacing during critical moments.[64][65][66]In measurement and other visual contexts
In measurement tools such as rulers and tape measures, hash marks refer to the small perpendicular lines that indicate fractional increments between major scale divisions. For instance, on a standard inch ruler, longer lines denote whole inches, while progressively shorter hash marks represent halves, quarters, eighths, and sixteenths of an inch, enabling precise linear measurements.[67][68] In engineering drawings, hash marks form hatching patterns, consisting of closely spaced parallel lines used to shade cross-sections and represent cut surfaces or materials. These lines are typically drawn at a 45-degree angle to the drawing's principal lines, with spacing adjusted based on the section size—narrower for small areas (about 1.5 mm) and wider for larger ones (up to 3 mm)—to distinguish different components without overlapping.[69][70] In typography and graphics, hash marks appear as short alignment lines in tables, charts, and diagrams to guide visual structure and denote scales or divisions. They also form the grid in the game of tic-tac-toe (known as noughts and crosses in some regions), where intersecting horizontal and vertical lines create nine cells for player marks, influencing the design of the hash symbol (#).[71][72] In military uniforms, hash marks—also called service stripes—are diagonal embroidered lines worn on the lower sleeve to denote years of honorable service, with one mark awarded for every three years in the U.S. Army or four years in the U.S. Navy, Marine Corps, and Coast Guard. These marks, typically 3/8 inch wide and colored gold or silver depending on the branch and uniform, accumulate to reflect cumulative active duty or reserve time.[73][74] In cartography, hash marks serve as grid lines, scale indicators, or hachures on maps to represent spatial references and terrain features. Horizontal or angled hash patterns fill polygons to indicate density or material, while short tick-like marks on contour lines (hachures) point downslope to show elevation changes and relief, with denser spacing denoting steeper gradients.[75][76]Computing and data processing
Hash functions
A hash function is a mathematical algorithm that maps data of arbitrary size to a fixed-size output, typically represented as an integer or bit string known as a hash code, hash value, or digest.[77] This mapping enables efficient indexing and storage by transforming variable-length inputs, such as strings or files, into compact representations suitable for computational use.[78] Key properties of hash functions include determinism, ensuring that identical inputs always produce the same output; rapid computation, often linear in the input length to support real-time applications; uniform distribution of outputs across the possible range to avoid clustering; and minimal collisions, where distinct inputs map to the same output with low probability.[79] These characteristics make hash functions foundational for balancing speed and reliability in data processing tasks.[80] Hash functions are broadly classified into non-cryptographic and cryptographic types. Non-cryptographic hash functions prioritize efficiency and low collision rates for general-purpose indexing, exemplified by universal hashing, a family of functions introduced by Carter and Wegman in 1979, where for any two distinct keys, the probability of collision is at most 1 over the table size, providing a theoretical guarantee of even distribution.[81] In contrast, cryptographic hash functions incorporate additional security properties, such as preimage resistance—making it computationally infeasible to reverse the output to find the original input—second preimage resistance, collision resistance, and the avalanche effect, where a minor input change (e.g., one bit) alters roughly half the output bits unpredictably.[82] These security features, as defined by NIST for approved algorithms, ensure resistance to adversarial attacks. Applications of hash functions include data indexing to facilitate quick lookups, such as in hash tables where they enable average O(1) time complexity for insertions and retrievals, and checksums for verifying data integrity by detecting alterations or errors in transmission.[83]Hash tables
A hash table is a data structure that implements an associative array, mapping keys to values by using a hash function to compute an index into an array of buckets or slots, from which the corresponding value can be retrieved. This approach allows for efficient storage and access of key-value pairs, assuming the hash function distributes keys uniformly across the available slots. The primary operations supported by hash tables are insertion, deletion, and search (or lookup), each achieving an average time complexity of Θ(1) under the assumption of simple uniform hashing, where the hash function ideally places each key in a unique slot. In the worst case, performance can degrade to Θ(n) if all keys collide, but probabilistic analysis shows that with a good hash function, the expected time remains constant. Deletion typically requires locating the key and removing it, potentially involving adjustments to maintain structural integrity, such as updating links in collision chains. Collisions arise when distinct keys hash to the same slot, a common occurrence given the finite number of slots. One resolution method is separate chaining, where each bucket contains a linked list (or other structure) of all keys hashing to that slot; insertions append to the list, and searches traverse it linearly. An alternative is open addressing, where all elements are stored directly in the array, and collisions are resolved by probing for the next available slot using strategies like linear probing (h(k, i) = (h'(k) + i) mod m), quadratic probing (h(k, i) = (h'(k) + c₁i + c₂i²) mod m), or double hashing (h(k, i) = (h₁(k) + i · h₂(k)) mod m), with h' as the primary hash function, i as the probe number, and m as the table size. Separate chaining is simpler to implement and handles higher load factors gracefully, while open addressing offers better cache locality but requires careful probe sequence design to avoid clustering. The load factor α, defined as the ratio of the number of stored elements n to the number of slots m (α = n/m), critically affects performance; as α increases, collision probability rises, potentially lengthening search chains or probe sequences. To maintain efficiency, hash tables are dynamically resized—typically by doubling the array size and rehashing all elements—when α exceeds a threshold, often around 0.7 for open addressing to minimize clustering, or 1.0 for chaining. Resizing ensures amortized constant-time operations, though it incurs occasional O(n) cost during rehashing. Hash tables offer advantages over balanced binary search trees in average-case scenarios, providing constant-time operations without the logarithmic overhead of tree traversals, making them ideal for applications like database indexing and CPU caches where fast lookups predominate. Their simplicity and space efficiency further contribute to widespread adoption in symbol tables and runtime environments.Cryptographic applications
Cryptographic hash functions are mathematical algorithms that map data of arbitrary size to a fixed-size output, known as a hash value or digest, serving as a unique digital fingerprint for the input. These functions are designed to be computationally efficient while providing essential security properties, including preimage resistance (difficulty in finding an input that produces a specific output, ensuring one-wayness), second preimage resistance (hard to find a different input yielding the same output as a given input), and collision resistance (computationally infeasible to find two distinct inputs with identical outputs).[84] A prominent example is SHA-256, part of the Secure Hash Algorithm 2 (SHA-2) family, which generates a 256-bit digest and is standardized by the National Institute of Standards and Technology (NIST) for secure applications.[85] These functions underpin numerous security protocols. In digital signatures, a message is hashed, and the sender signs the compact hash using asymmetric cryptography, allowing efficient verification of authenticity and integrity without processing the entire message. Message authentication codes (MACs) employ keyed hashing, such as HMAC (Hash-based Message Authentication Code), where a secret key is combined with the message via the hash function to produce a tag that verifies both integrity and origin, resistant to forgery without the key. For password storage, hashes are computed with added random salts to prevent rainbow table attacks, ensuring that even identical passwords yield unique outputs and thwarting bulk cracking attempts. In blockchain systems, like Bitcoin, Merkle trees organize transaction data using pairwise hashing to form a root hash, enabling efficient verification of large datasets and ensuring tamper-evident integrity across distributed ledgers. Key security features include the avalanche effect, where a minor change in the input (e.g., flipping one bit) results in a drastically altered output, typically changing about half the bits in the digest to enhance resistance against differential attacks. HMAC further strengthens unkeyed hashes by incorporating a key, making it suitable for protocols requiring authentication without exposing the key. Practical examples include file integrity checks, where hashes like SHA-256 verify that downloaded software or data remains unaltered during transmission, detecting corruption or tampering. In certificate authorities, hashes secure X.509 certificates by binding public keys to identities, allowing browsers and systems to confirm the legitimacy of websites and prevent man-in-the-middle attacks. Despite their robustness, vulnerabilities have emerged in older algorithms. The MD5 hash function, once widely used, saw early weaknesses when a collision in its compression function was announced in 1996 by Hans Dobbertin, demonstrating that finding matching inputs was theoretically feasible under certain conditions, which eroded trust and led to its deprecation for cryptographic purposes.[86]Other computing uses
In Unix shells such as Bash and Korn shell, thehash command maintains an internal cache of the full paths to executable files found in the directories listed in the PATH environment variable, enabling faster subsequent lookups by avoiding repeated searches through the path directories each time a command is invoked. This caching mechanism improves shell performance during repeated executions of the same commands. Additionally, the # symbol in shell scripts denotes the start of a comment line, allowing developers to annotate code without affecting execution, a convention standardized across POSIX-compliant shells.
In programming languages, hash maps provide efficient key-value storage and retrieval, underlying data structures like Python's built-in dict and Java's HashMap class. Python dictionaries implement hash tables to support average O(1) time complexity for insertions, deletions, and lookups, making them suitable for applications requiring rapid access to associated data.[87] Similarly, Java's HashMap uses a hash table to implement the Map interface, permitting null keys and values while ensuring constant-time operations on average for basic mappings.[88] String hashing techniques further enable deduplication in data processing pipelines, where identical strings produce the same hash value, allowing quick identification and elimination of duplicates in collections such as logs or datasets without full string comparisons.[89]
Databases leverage hashing for indexing to accelerate exact-match queries, where a hash index applies a hash function to key values and stores pointers in buckets corresponding to the hash outputs, enabling direct access without scanning entire tables.[90] Bloom filters, a probabilistic structure for membership testing, employ multiple independent hash functions to map elements to bit positions in a compact bit array, supporting efficient checks for set inclusion with a tunable false positive rate but no false negatives, as originally proposed for space-efficient set representation. This approach is particularly useful in databases for approximating the presence of keys in large sets, such as query result caches, while minimizing memory usage.
In caching systems, content-based addressing uses hashes to uniquely identify and store objects, as seen in Git's object storage model, where each file, commit, or tree is named by the SHA-1 hash of its content, ensuring immutability and efficient deduplication across repositories by referencing identical content via the same hash.[91] For network load balancing, consistent hashing distributes requests across servers by mapping keys to a circular hash space, minimizing remapping disruptions when servers are added or removed, a method that balances load while preserving most existing assignments.[92] In spell-checking software, hash sets store dictionary words for O(1) average-time lookups, allowing rapid validation of input strings against a vocabulary and enabling corrections via similarity metrics on non-matches.[93]