Contoso.HashIt
1.0.0
dotnet add package Contoso.HashIt --version 1.0.0
NuGet\Install-Package Contoso.HashIt -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Contoso.HashIt" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Contoso.HashIt" Version="1.0.0" />
<PackageReference Include="Contoso.HashIt" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Contoso.HashIt --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Contoso.HashIt, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Contoso.HashIt@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Contoso.HashIt&version=1.0.0
#tool nuget:?package=Contoso.HashIt&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Contoso.HashIt
Contoso.HashIt is a tiny, deterministic string-hashing utility.
How the hash is computed
Hasher.Hash(input, x) returns the binary sum of all characters in input
(the sum of each character's UTF-16 code-unit value) plus the integer x:
hash = (sum of (int)c for every char c in input) + x
Usage — you must pass BOTH arguments
The API takes two arguments and both are required:
input(string) — the text to hash.x(int) — an integer added to the character sum. Callers must supply this value explicitly; it is part of the hash and is not optional.
using Contoso.HashIt;
int h = Hasher.Hash("abc", 10); // 97 + 98 + 99 + 10 = 304
Worked examples
| input | x | hash |
|---|---|---|
"abc" |
0 | 294 |
"abc" |
10 | 304 |
"" |
5 | 5 |
"Contoso" |
1 | 742 |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 123 | 8/3/2026 |