diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-05 23:05:13 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-05 23:05:13 +0000 |
commit | aed148fd3035e7392e52a71f82b576f52d8986c3 (patch) | |
tree | fcbb1a9141025bce363ae59127a81fd288a2f414 /src/libutil/str_util.h | |
parent | 1e82c502dc8601a95e80379eccfd1c8cc9ed5c91 (diff) | |
download | rspamd-aed148fd3035e7392e52a71f82b576f52d8986c3.tar.gz rspamd-aed148fd3035e7392e52a71f82b576f52d8986c3.zip |
Add fixed hex/base32 encode and decode routines
Diffstat (limited to 'src/libutil/str_util.h')
-rw-r--r-- | src/libutil/str_util.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index 2f16db37d..8e26b37dc 100644 --- a/src/libutil/str_util.h +++ b/src/libutil/str_util.h @@ -132,6 +132,50 @@ gchar * rspamd_encode_hex (const guchar *in, gsize inlen); guchar* rspamd_decode_hex (const gchar *in, gsize inlen); /** + * Encode string using base32 encoding + * @param in input + * @param inlen input length + * @param out output buf + * @param outlen output buf len + * @return encoded len if `outlen` is enough to encode `inlen` + */ +gint rspamd_encode_base32_buf (const guchar *in, gsize inlen, gchar *out, + gsize outlen); + +/** + * Decode string using base32 encoding + * @param in input + * @param inlen input length + * @param out output buf (may overlap with `in`) + * @param outlen output buf len + * @return decoded len if in is valid base32 and `outlen` is enough to encode `inlen` + */ +gint rspamd_decode_base32_buf (const gchar *in, gsize inlen, + guchar *out, gsize outlen); + +/** + * Encode string using hex encoding + * @param in input + * @param inlen input length + * @param out output buf + * @param outlen output buf len + * @return encoded len if `outlen` is enough to encode `inlen` + */ +gint rspamd_encode_hex_buf (const guchar *in, gsize inlen, gchar *out, + gsize outlen); + +/** + * Decode string using hex encoding + * @param in input + * @param inlen input length + * @param out output buf (may overlap with `in`) + * @param outlen output buf len + * @return decoded len if in is valid hex and `outlen` is enough to encode `inlen` + */ +gint rspamd_decode_hex_buf (const gchar *in, gsize inlen, + guchar *out, gsize outlen); + +/** * Encode string using base64 encoding * @param in input * @param inlen input length |