❯ git submodule init
Submodule 'argon2-src' ([email protected]:P-H-C/phc-winner-argon2.git) registered for path 'argon2-src'
❯ git submodule update
Cloning into '/Users/iskiridomov/Personal/Argon2.Bindings/argon2-src'...
Submodule path 'argon2-src': checked out 'f57e61e19229e23c4445b85494dbf7c07de721cb'
❯ cd argon2-src
❯ make
Building without optimizations
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread src/argon2.c src/core.c src/blake2/blake2b.c src/thread.c src/encoding.c src/ref.c src/run.c -o argon2
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread -dynamiclib -install_name /usr/lib/libargon2.1.dylib src/argon2.c src/core.c src/blake2/blake2b.c src/thread.c src/encoding.c src/ref.c -o libargon2.1.dylib
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread -c -o src/argon2.o src/argon2.c
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread -c -o src/core.o src/core.c
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread -c -o src/blake2/blake2b.o src/blake2/blake2b.c
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread -c -o src/thread.o src/thread.c
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread -c -o src/encoding.o src/encoding.c
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread -c -o src/ref.o src/ref.c
ar rcs libargon2.a src/argon2.o src/core.o src/blake2/blake2b.o src/thread.o src/encoding.o src/ref.o
sed '/^##.*$/d; s#@PREFIX@#/usr#g; s#@EXTRA_LIBS@##g; s#@UPSTREAM_VER@#ZERO#g; s#@HOST_MULTIARCH@#lib#g; s#@INCLUDE@#include#g;' < 'libargon2.pc.in' > 'libargon2.pc'
<Content Include="runtimes\osx-arm64\native\libargon2.dylib">
<Pack>true</Pack>
<PackagePath>runtimes/osx-arm64/native</PackagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
❯ dotnet build
MSBuild version 17.4.0+18d5aef85 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
Argon2 -> /Users/iskiridomov/Personal/Argon2.Bindings/bin/Debug/net6.0/Argon2.Bindings.dll
Argon2 -> /Users/iskiridomov/Personal/Argon2.Bindings/bin/Debug/net7.0/Argon2.Bindings.dll
Build succeeded.
0 Warning(s)
0 Error(s)
nuget add /Users/iskiridomov/Personal/Argon2.Bindings/bin/Debug/Argon2.Bindings.1.14.3.nupkg -Source ./packages
dotnet add package Argon2.Bindings -s ./packages
var hasher = new Argon2PasswordHasher();
var myhash = hasher.Hash("mypassword");
_logger.LogInformation(myhash);
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.Security.Cryptography.Argon2Exception: Error during Argon2 hashing: (-3) -3
at System.Security.Cryptography.Argon2PasswordHasher.Hash(ReadOnlySpan`1 password, ReadOnlySpan`1 salt, Span`1 hash)
at System.Security.Cryptography.Argon2PasswordHasher.Hash(ReadOnlySpan`1 password, ReadOnlySpan`1 salt)
at System.Security.Cryptography.Argon2PasswordHasher.Hash(ReadOnlySpan`1 password)
at Marketplace.Controllers.WeatherForecastController.Get() in /Users/iskiridomov/RiderProjects/Marketplace/Marketplace/Controllers/WeatherForecastController.cs:line 27
at lambda_method2(Closure, Object, Object[])
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
❯ chmod +x argon2
❯ echo -n "123456789012345678901234567890" | ./argon2 "salzwasser" -i -t 3 -m 12 -p 1
Type: Argon2i
Iterations: 3
Memory: 4096 KiB
Parallelism: 1
Hash: 545a0252727d0518ac160d122d1dad04fa228c706f90d60bf561a5c0f5acb52d
Encoded: $argon2i$v=19$m=4096,t=3,p=1$c2Fsendhc3Nlcg$VFoCUnJ9BRisFg0SLR2tBPoijHBvkNYL9WGlwPWstS0
0.013 seconds
Verification ok