plusaes icon indicating copy to clipboard operation
plusaes copied to clipboard

Add encode feature

Open flaviu22 opened this issue 3 years ago • 2 comments

This is not an issue, it is only a proposal: would be nice if you add an encoding feature ?

I have tested your code, and on this step:

	plusaes::encrypt_cbc((unsigned char*)raw_data.data(), raw_data.size(), &key[0], key.size(), &iv, &encrypted[0], encrypted.size(), true);
	// fb 7b ae 95 d5 0f c5 6f 43 7d 14 6b 6a 29 15 70
	std::cout << encrypted.data() << std::endl;

And here is the listing of the outome:

√{«ò╒☼┼oC}¶kj)§p²²²²

It would be nice if you add an encoding option for this encrypted string, in order to have intelligibile chars instead of these weird chars ?

flaviu22 avatar Apr 12 '22 11:04 flaviu22

for (const auto& entry : encrypted) { std::stringstream hex; uint32_t to_hex = entry; hex << std::hex << to_hex; std::cout << hex.str() << " "; } std::cout << std::endl;

minhook avatar May 08 '22 12:05 minhook

I think that it is not a feature of the encryption (plusaes) library. It is a feature of binary handling.

For example, we can use std::string as input data or output buffer (The example code in the README is it).

My image.

SmartBytes buf(data_size);

plusaes::decrypt_cbc(
    encrypted, encrypted_size, key, key_size, iv,
    buf.data(), buf.size(), // Pass as output buffer
    &padded_size);

buf.to_string(kEncodingUtf8);
buf.to_base64()

kkAyataka avatar May 08 '22 13:05 kkAyataka

No reply, out of scope

kkAyataka avatar Oct 02 '22 02:10 kkAyataka