Use safer characters for nip46 secrets

This commit is contained in:
Mike Dilger 2024-04-20 09:19:45 +12:00
parent be4f95cc54
commit 9174ac3f4a

View File

@ -17,10 +17,15 @@ pub struct Nip46UnconnectedServer {
impl Nip46UnconnectedServer {
pub fn new(name: String, relays: Vec<RelayUrl>) -> Nip46UnconnectedServer {
let connect_secret = textnonce::TextNonce::sized_urlsafe(32)
let mut connect_secret = textnonce::TextNonce::sized_urlsafe(32)
.unwrap()
.into_string();
// Map - and _ back into other characters. We don't care if the result is
// uniformly random or not.
connect_secret = connect_secret.replace("-", "0");
connect_secret = connect_secret.replace("_", "1");
Nip46UnconnectedServer {
connect_secret,
name,