I want to transform the cypher in its base 256 of length xLen cypher (cypher is an instance of mpz_class
). In order to do this I use the code below:
//Write the integer x in its unique xLen-digit representation in base 256
string str;
str=cypher.get_str(256);
//Print string figure by figure separated by space
for(int i=0;i<(int)str.length();i++){
if(i%256==0)
cout<<" "<<str[i];
else
cout<<str[i];
}
Unfortunately, I receive
terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid Aborted (core dumped)
I strongly believe it's because of str=cypher.get_str(256)
because changing the base to 10 returns no error.
I would appreciate a lot your ideas how I could replace the block. Thank you!