src: include warning in the secret file

This commit is contained in:
Ujjwal Sharma 2021-03-25 14:41:55 +05:30
parent c3fe4c7230
commit 4111aed599
Signed by: ryzokuken
GPG Key ID: 460B292812C67D9F
2 changed files with 25 additions and 1 deletions

View File

@ -59,7 +59,16 @@ impl SSBKeypair for Keypair {
} else {
let mut csprng = OsRng {};
let keypair = Keypair::generate(&mut csprng);
std::fs::write(path, keypair.to_json().pretty(2)).unwrap();
let keypair_json = keypair.to_json();
std::fs::write(
path,
format!(
include_str!("warning.txt"),
keys = keypair_json.pretty(2),
id = keypair_json["id"]
),
)
.unwrap();
keypair
}
}

15
src/warning.txt Normal file
View File

@ -0,0 +1,15 @@
# WARNING: Never show this to anyone.
# WARNING: Never edit it or use it on multiple devices at once.
#
# This is your SECRET, it gives you magical powers. With your secret you can
# sign your messages so that your friends can verify that the messages came
# from you. If anyone learns your secret, they can use it to impersonate you.
#
# If you use this secret on more than one device you will create a fork and
# your friends will stop replicating your content.
#
{keys}
#
# The only part of this file that's safe to share is your public name:
#
# {id}