diff options
author | defanor <defanor@uberspace.net> | 2023-09-29 20:24:16 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2023-09-29 20:24:16 +0300 |
commit | ccdb748c81abc9bb30b8989e27d22bbbb219f9a0 (patch) | |
tree | 295be2ea605c8acbe56116ea3ce119b99e3e0440 /src/rexmpp_random.c | |
parent | 04e6fd5194481798bc30abc7a690664d5af36aeb (diff) |
Add more checks, tests, and documentation
Diffstat (limited to 'src/rexmpp_random.c')
-rw-r--r-- | src/rexmpp_random.c | 9 |
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; +} |