summaryrefslogtreecommitdiffabout
path: root/src/eyetil.cc
Unidiff
Diffstat (limited to 'src/eyetil.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyetil.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/eyetil.cc b/src/eyetil.cc
index fe816a6..7669cb6 100644
--- a/src/eyetil.cc
+++ b/src/eyetil.cc
@@ -9,6 +9,11 @@
9#include <openssl/md5.h> 9#include <openssl/md5.h>
10#include "eyetil.h" 10#include "eyetil.h"
11 11
12#include "config.h"
13#ifdef HAVE_LIBUUID
14# include <uuid/uuid.h>
15#endif
16
12binary_t& binary_t::from_hex(const std::string& h) { 17binary_t& binary_t::from_hex(const std::string& h) {
13 std::string::size_type hs = h.length(); 18 std::string::size_type hs = h.length();
14 if(hs&1) 19 if(hs&1)
@@ -32,6 +37,18 @@ binary_t& binary_t::from_data(const void *d,size_t s) {
32 return *this; 37 return *this;
33} 38}
34 39
40binary_t& binary_t::make_nonce() {
41#ifdef HAVE_LIBUUID
42 uuid_t uuid;
43 uuid_generate(uuid);
44 from_data((unsigned char*)uuid,sizeof(uuid));
45#else
46 resize(16);
47 std::generate_n(begin(),16,rand);
48#endif /* HAVE_LIBUUID */
49 return *this;
50}
51
35std::string binary_t::hex() const { 52std::string binary_t::hex() const {
36 std::string rv; 53 std::string rv;
37 rv.reserve((size()<<1)+1); 54 rv.reserve((size()<<1)+1);