//----------------------------------------------------------------------------- // ___ __ _ _ // / _ \__ _ _ __ ___ ___ / /(_)_ __ | | __ // / /_)/ _` | '__/ __|/ _ \/ / | | '_ \| |/ / // / ___/ (_| | | \__ \ __/ /__| | | | | < // \/ \__,_|_| |___/\___\____/_|_| |_|_|\_\ . // //----------------------------------------------------------------------------- // Author: Kurt Sassenrath // Module: proto // // Session ID implementation // // Copyright (c) 2023 Kurt Sassenrath. // // License TBD. //----------------------------------------------------------------------------- #include "parselink/proto/session_id.h" #include "hydrogen.h" namespace { void ensure_initialized() { static auto init_crng [[maybe_unused]] = [] { return hydro_init(); }(); } template auto get_random_bytes() { ensure_initialized(); std::array out; hydro_random_buf(out.data(), N); return out; } } using namespace parselink::proto; session_id::session_id() noexcept : bytes_(get_random_bytes<32>()) {}