Directly saving/loading public/private keys from files

9 views
Skip to first unread message

fbenhamo

unread,
Mar 14, 2017, 8:21:08 PM3/14/17
to Crypto++ Users
Hi,

In https://www.cryptopp.com/wiki/Keys_and_Formats#Saving_Keys, if I understand correctly, the key is first saved into a ByteQueue before being saved in a file. 

Is there any reason (except mimicking validate2.cpp) not to directly save the key to a file, as follows?
void SavePublicKey(const string& filename, const PublicKey& key)
{
    FileSink file(filename.c_str());
    key.Save(file);
    file.MessageEnd();
}

Thanks,
Best,
Fabrice

Jeffrey Walton

unread,
Mar 15, 2017, 5:27:05 AM3/15/17
to Crypto++ Users


Is there any reason (except mimicking validate2.cpp) not to directly save the key to a file, as follows?
void SavePublicKey(const string& filename, const PublicKey& key)
{
    FileSink file(filename.c_str());
    key.Save(file);
    file.MessageEnd();
}

That should work as well.

Jeff
Reply all
Reply to author
Forward
0 new messages