#include "clave_variable.h"
#include <iostream>
-ClaveVariable::ClaveVariable (const std::string &s)
+ClaveVariable::ClaveVariable (const std::string &s, uint bd)
{
data = s;
+ block_data = bd;
}
ClaveVariable::ClaveVariable (uchar *n)
str[len] = '\0';
data = std::string ((const char *)(str));
delete [] str;
+ n += data.size () * sizeof (uchar);
+ memcpy (&block_data, n, sizeof (uint));
+
raw_data = data;
}
uint ClaveVariable::Size () const
{
- return data.size ()*sizeof (uchar)+sizeof (uint);
+ return data.size ()*sizeof (uchar)+sizeof (uint)*2;
}
uchar *ClaveVariable::ToArray () const
uchar *out;
uint len = data.size ();
out = new uchar[Size ()];
+ int x = 0;
memcpy (out, &len, sizeof (uint));
- memcpy (out+sizeof(uint), data.c_str (), data.size ()*sizeof (uchar));
+ x += sizeof (uint);
+ memcpy (out+x, data.c_str (), data.size ()*sizeof (uchar));
+ x += data.size () * sizeof (uchar);
+ memcpy (out+x, &block_data, sizeof (uint));
+
return out;
}