// -*- coding: utf-8 -*- // // Copyright (C) 2024 Michael Büsch // // Licensed under the Apache License version 2.0 // or the MIT license, at your option. // SPDX-License-Identifier: Apache-2.0 OR MIT use anyhow as ah; use letmein_conf::Config; use letmein_proto::{secure_random, Key, UserId}; use std::sync::Arc; /// Generate a new truly random and secure user key. pub async fn run_genkey(conf: Arc, user: Option) -> ah::Result<()> { let user = user.unwrap_or_else(|| conf.default_user()); let key: Key = secure_random(); let key: Vec = key.iter().map(|b| format!("{b:02X}")).collect(); let key: String = key.join(""); println!("{user} = {key}"); Ok(()) } // vim: ts=4 sw=4 expandtab