Hello, I am using the CryptoPP::Integer class for RSA operations. My program
needs to interact with PHP functions on a server.

My issue comes into play when storing RSA keys, that they appear to remain
in CryptoPP's Integer format, not hex. So after looking around online I
found an implementation for Integer -> std::string

std::string IntegerToString(const Integer refs) {
   std::ostrstream oss;
   oss << refs;
   oss << std::hex << refs; // use this for hex output
   std::string s(oss.str());
   return s;// output is now in s
}

however, this makes some really interesting decimal output on some of the
numbers, so I added a line to truncate these decimals

std::string xxz568::IntegerToString(const Integer refs) {
   std::ostrstream oss;
   oss << refs;
   oss << std::hex << refs; // use this for hex output
   std::string s(oss.str());
   s = s.substr(0, s.find_first_of("."));
   return s;// output is now in s
}

My only problem now lies with the fact that when I feed a hexidecimal string
to the Integer constructor, and then call the above function on it, all of
the hex values (a-f) are gone, but the numeric values still remain.

How can I fix this?
-- 
View this message in context: 
http://old.nabble.com/Integer-and-Back-tp30887075p30887075.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.

-- 
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