On Sep 18, 6:19 pm, Niij <[email protected]> wrote:
> Hi,
>
> I'm in the same situation as you but with EC scheme, I used Harry's
> code (http://groups.google.com/group/cryptopp-users/browse_thread/
> thread/e58e46f0e8558f2b/022e858d15529859?lnk=gst&q=How+to+save+public
> +key+and+private+key+for+#022e858d15529859)
>  to get the private and public key written on files and now I 'd like
> to Load the public key from the public.key file using the Load()
> method from PublicKey class
>
> Here is the portion of my code  :
>         CryptoPP::ECIES < ECC_ALGORITHM >::Encryptor Encryptor
> (publicKey);
>
>         // Public Key Loading
>
>          std::ifstream file2("Public.key", std::ios::in);
>          string public_k;
>          if(file2)
>            {
>                 getline(file2, public_k);  //  put the first line on
> "public_k"
>                 cout <<  "the public key " << public_k << endl ;  //
> display the line
>                 file2.close();
>         }
>         else
>         cerr << "impossible to open the file!" << endl;
>
>         publicKey.Load(public_k);
>
> -------------
>
> After compiling I got the following error :
>  error: no matching function for call to
> ‘CryptoPP::DL_PublicKey_EC<CryptoPP::ECP>::Load(std::string&)’
> /usr/include/cryptopp/asn.h:240: note: candidates are: void
> CryptoPP::ASN1CryptoMaterial<BASE>::Load(CryptoPP::BufferedTransformation&)
> [with BASE = CryptoPP::PublicKey]
>
> The problem seems to be the choice of the parameter type for Load() ,
> which should  be BufferedTransformation&. How can I convert from
> string to this type then ?
You might want to use a FileSource rather than an istream directly. A
FileSource is a BufferedTransformation.

Base64 encoding and decoding is covered near the bottom of
http://www.cryptopp.com/wiki/Keys_and_formats.

Jeff

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to