On Feb 9, 4:22 pm, "Robert F." <[email protected]> wrote: > 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? Either prepend "0x" or append "h" to the hexadecimal encoded string.
The code for Integer is at http://www.cryptopp.com/docs/ref/integer_8cpp_source.html. The function of interest is StringToInteger, near line 2970. Jeff 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.
