On Thursday, May 30, 2019 at 6:45:01 AM UTC-4, Ahlem wrote:
>
> ...
>
> unserialization of Integer (cryptopp) in ns3
> uint8_t l = i.ReadU8 (); //récupérer la longueur
> double gg= (double) l;
> int len = ( int ) gg;
> //cout<< "len deserialz "<<len<<" \n"<<endl;
> len=310;
> // cout<< "len serialz "<<len<<" \n"<<endl;
> std::istringstream iss;
> string s="";
> //construction du string
> for (int j = 0; j < len; j++)
> {
> uint8_t ci = i.ReadU8();
> int cii = (int) ci;
> char c = char(cii);
> //cout<< "le caractère est :cc "<<c<<" \n"<<endl;
> s+=c; //concaténer caractère par caractère pour récupérer toute la chaine
> }
> const char* cstr = s.c_str() ;
> //j'ai utiliser ce constructeur pour récupérer le Integer, Integer(const
> char *str)
> Integer g = Integer(cstr);
> m_n=g;
>
This may be a little easier. It uses the string from the earlier oss.str().
No need to convert to a binary array. Leave it as an ASCII string.
std::string x = "17a94c...2d63c8h";
StringSource ss(x, true, new HexDecoder);
Integer n(ss, ss.MaxRetrievable());
Jeff
--
You received this message because you are subscribed to "Crypto++ Users". More
information about Crypto++ and this group is available at
http://www.cryptopp.com and
http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/cryptopp-users/46560f22-b540-49bd-a37f-e3aec0b305fb%40googlegroups.com.