Get bytes from std::string in C++

后端 未结 7 1254
遇见更好的自我
遇见更好的自我 2020-12-08 14:12

I\'m working in a C++ unmanaged project.

I need to know how can I take a string like this \"some data to encrypt\" and get a byte[] array which I\'m gonna use as the

7条回答
  •  伪装坚强ぢ
    2020-12-08 15:02

    Normally, encryption functions take

    encrypt(const void *ptr, size_t bufferSize);
    

    as arguments. You can pass c_str and length directly:

    encrypt(strng.c_str(), strng.length());
    

    This way, extra space is allocated or wasted.

提交回复
热议问题