Conversion into hexadecimal using C++
First off, your formatting is not very good.  It makes it difficult to read.  I would suggest looking at your IDE's menu options and use the format command.

It seems like you're trying to reinvent the wheel here. The &lt;ios&gt; header contains that option already.  To write the vector to a file as base 16 numbers, you can do that directly in the writeFile function:

void writeFile(std::string_view str, std::vector&lt;unsigned char&gt; const &amp; v)
{

    assert(str.data() != nullptr);
    std::ofstream f(str.data(), std::ios::binary);
    for(auto c : v)
    {
        if(f.is_open())
        {
            f &lt;&lt; std::hex &lt;&lt; (int)c;
        }
    }
    f.close();
}


If creating the string is more to the point than writing to the file, you can use a stringstream and do the same thing:

#include &lt;sstream&gt;

std::string hexify(std::vector&lt;unsigned char&gt; const &amp; v)
{
    std::stringstream ss;
    for(auto c : v)
    {
        ss &lt;&lt; std::hex &lt;&lt; (int)c;
    }
    return ss.str();
}


If characters with single digit character codes are to be used and the leading 0 is required, it's simply a matter of adding a couple of functions from the &lt;iomanip&gt; header:

&lt;&lt; std::setw(2) &lt;&lt; std::setfill('0') &lt;&lt; std::hex &lt;&lt; (int)c


If reinventing the wheel is the point, first there's a tag for that.

When you have a need for literal (magic) use a constant variable. It gives meaning to anonymous values.

Generally speaking when you're using iterators in a loop, since end() is past the last element, it's better to use not equals(!=) instead of less than.