Boost logo

Boost :

From: Stephen Torri (storri_at_[hidden])
Date: 2003-11-14 01:07:48


I am trying to track down a problem in a program that does encryption. I
want to convert input and output strings to a encrypted file to hex to
see what is happening. Below is my first attempt to do this.
Unfortunately I get an assert fail from boost.

  format hex_format (" %1% ");
  hex_format.modify_item (0, group (hex, setw(2)));

  cout << "Hex: ";
  for (unsigned int i = 0; i < plaintext.size(); ++i) {
    cout << hex_format % plaintext[i];
  }
  cout << endl;

The ideal output I want as an example is:

Hex: 04 95 40 39 40 59

Boost version 1.30.2.

-----------------
Error output:
-----------------

(gdb) #0 0x4f309e81 in kill () from /lib/libc.so.6
#1 0x4f4fb54d in pthread_kill () from /lib/libpthread.so.0
#2 0x4f4fb86b in raise () from /lib/libpthread.so.0
#3 0x4f309c34 in raise () from /lib/libc.so.6
#4 0x4f30b19b in abort () from /lib/libc.so.6
#5 0x4f286837 in __cxxabiv1::__terminate(void (*)()) ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5
#6 0x4f286878 in std::terminate() ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5
#7 0x4f286a1e in __cxa_throw ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5
#8 0x0806685c in void
boost::throw_exception<boost::io::out_of_range>(boost::io::out_of_range
const&) (e=@0xb9551cb0) at throw_exception.hpp:38
#9 0x0806564d in boost::basic_format<char, std::char_traits<char> >&
boost::io::detail::modify_item_body<char, std::char_traits<char>,
boost::io::detail::group1<boost::io::detail::group2<std::ios_base&
(*)(std::ios_base&), std::_Setw const&> > >(boost::basic_format<char,
std::char_traits<char> >&, int,
boost::io::detail::group1<boost::io::detail::group2<std::ios_base&
(*)(std::ios_base&), std::_Setw const&> > const&) (self=@0xb9551df0,
itemN=0, manipulator=@0xb9551de8)
    at format_implementation.hpp:252
#10 0x08064409 in
modify_item<boost::io::detail::group1<boost::io::detail::group2<std::ios_base&(*)(std::ios_base&), const std::_Setw&> > > (this=0xb9551df0,
    itemN=0, manipulator=@0xb9551de8) at format_class.hpp:87
#11 0x08062ab2 in AES_CFB_CipherEngine::encrypt(std::string)
(this=0x81457d0,
    plaintext=
        {static npos = 4294967295, _M_dataplus = {<allocator<char>> =
{<No data ---Type <return> to continue, or q <return> to quit---Quit
) at aes_encryption.cpp:46

<... Error messages above #11 are application specific ...>

Stephen

-- 
Stephen Torri
GPG Key: http://www.cs.wustl.edu/~storri/storri.asc



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk