Quick actions

cmd+k|ctrl+k

Navigation

Languages

UDP/Argon2

Snippet info

Language

Raku

Visibility

unlisted

Author

legacy-anonymous

Created

2025-10-15T12:19:40.617156Z

Updated

2025-10-15T12:19:40.617156Z

#!/usr/bin/env raku

use Crypt::Argon2;
use Log::Async <info color>;

unit sub MAIN(
    Str  :a(:$address) = 'localhost', #= Address to bind
    UInt :p(:$port)    = 9988         #= Port to bind
);

given IO::Socket::Async.bind-udp($address, $port) -> $udp-server {
    $udp-server.Supply(:datagram).tap: {
        info "Got {.data.gist} from {.hostname}:{.port}";
        my $argon2hash = argon2-hash(.data.gist, :t_cost(11), :m_cost(64 * 1024), :parallelism(4), :hashlen(32));
        info "Argon2Hash: $argon2hash";
        $udp-server.print-to: .hostname, .port, "$argon2hash\n";
    }
}

info "Listening on udp://$address:$port";
react {
    whenever signal(SIGINT) { print "\r"; warning "(Ctrl-C) Bye !"; exit }
}
INFO