summaryrefslogtreecommitdiff
path: root/src/rexmpp_random.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rexmpp_random.c')
-rw-r--r--src/rexmpp_random.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/rexmpp_random.c b/src/rexmpp_random.c
index 8efabd3..11e2b73 100644
--- a/src/rexmpp_random.c
+++ b/src/rexmpp_random.c
@@ -7,6 +7,7 @@
*/
#include "config.h"
+#include "rexmpp_base64.h"
#ifdef HAVE_GCRYPT
#include <gcrypt.h>
@@ -23,3 +24,11 @@ void rexmpp_random_buf (void *buf, size_t len) {
arc4random_buf(buf, len);
#endif
}
+
+char *rexmpp_random_id () {
+ char buf_raw[18], *buf_base64 = NULL;
+ size_t buf_base64_len = 0;
+ rexmpp_random_buf(buf_raw, 18);
+ rexmpp_base64_to(buf_raw, 18, &buf_base64, &buf_base64_len);
+ return buf_base64;
+}