From af7d88b057fa4c84ab9096c6a1932bd5d34634ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Thu, 11 Aug 2022 10:05:09 -0400 Subject: [PATCH] crypto: allow to build all from std::string_view --- include/opendht/crypto.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 71a69beb..642eb461 100644 --- a/include/opendht/crypto.h +++ b/include/opendht/crypto.h @@ -120,7 +120,9 @@ struct OPENDHT_PUBLIC PublicKey inline Blob encrypt(const Blob& data) const { return encrypt(data.data(), data.size()); } - + inline Blob encrypt(std::string_view data) const { + return encrypt((const uint8_t*)data.data(), data.size()); + } void pack(Blob& b) const; int pack(uint8_t* out, size_t* out_len) const; void unpack(const uint8_t* dat, size_t dat_size); @@ -186,6 +188,7 @@ struct OPENDHT_PUBLIC PrivateKey * @returns the signature data. */ Blob sign(const uint8_t* data, size_t data_len) const; + inline Blob sign(std::string_view dat) const { return sign((const uint8_t*)dat.data(), dat.size()); } inline Blob sign(const Blob& dat) const { return sign(dat.data(), dat.size()); } /** -- GitLab