Use std::ostrstream and the << operator:

#include <strstream>

std::ostrstream oss;
CryptoPP::Integer i("123");
oss << i;
oss << std::ios::hex << i;    // use this for hex output
std::string s(oss.str());    // output is now in s

----- Original Message ----- From: "zqq_tt" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, December 02, 2006 3:05 PM
Subject: How can I convert Integer to string



  recently I find the crypto++ source code,I want to use ECP.
There is a question for me to resolve:
  How to convert integer to string?
  I find a message as this:
How to output a Integer as string(Decimal/Hex)? I just can do this:

        Integer plaintext;
       byte* buffer=new byte[1024];
       for (int i=0;i<plaintext.ByteCount();i++)
               buffer[plaintext.ByteCount()-1-i]=plaintext.GetByte(i);
       buffer[plaintext.ByteCount()]=0;
       StringSource(buffer,plaintext.ByteCount(), true,
        new HexEncoder(
            new FileSink(cout)));
But not fit me,How can I do?
--
View this message in context: http://www.nabble.com/How-can-I-convert-Integer-to-string-tf2742226.html#a7651065
Sent from the Crypto++ mailing list archive at Nabble.com.



Reply via email to