Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Packet - basic_string<unsigned char>  (Read 2063 times)

0 Members and 1 Guest are viewing this topic.

felaugmar

  • Guest
[Solved] Packet - basic_string<unsigned char>
« on: November 12, 2016, 12:25:13 am »
I'm using OpenSSL here;
When using AES cryptographic, it generates a Key and IV with the type unsigned char*.
It's easy to put into a std::string doing reinterpret_cast<char *> when generating.

But, why there's not those functions in Packet class?
Packet& Packet::operator >>(std::basic_string<unsigned char>& data)
Packet& Packet::operator <<(const std::basic_string<unsigned char>& data)

It's because they'll not be much used?

And I know, packing symmetric keys directly in mostly all cases is a bad idea.  ;D
« Last Edit: November 12, 2016, 02:52:35 am by felaugmar »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Packet - basic_string<unsigned char>
« Reply #1 on: November 12, 2016, 01:04:24 am »
Mostly because we can't provide overload for all possible types in the world. ;)

We already have overloads for:
char*
wchar_t*
std::string = std::basic_string<char>
std::wstring = std::basic_string<wchar_t>
sf::String

basic_string<unsigned char> is not really that common of a type, but if you really need it, I think you can provide your own overloads for it as free functions (I'm not certain if that actually works though).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

felaugmar

  • Guest
Re: Packet - basic_string<unsigned char>
« Reply #2 on: November 12, 2016, 02:51:56 am »
Yeah, it's not a very common type 😁