diff options
author | Berke Viktor <bviktor@hexchat.org> | 2012-10-25 21:08:26 +0200 |
---|---|---|
committer | Berke Viktor <bviktor@hexchat.org> | 2012-10-25 21:08:26 +0200 |
commit | 215325c0589927882389c22761af2db8beb985cd (patch) | |
tree | 66d43eda651ea6dd3d1685f49aae7a87eedd7377 /src/common/util.c | |
parent | f50a1bf1dd622e81b12b985a5388df386bf2bcfc (diff) |
Move SASL passphrase generation code to utils
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 5120c25a..f05a2c9e 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1966,3 +1966,23 @@ get_subdirs (const char *path) return dirlist; } + +char * +encode_sasl_pass (char *user, char *pass) +{ + int passlen; + char *buffer; + char *encoded; + + /* passphrase generation, nicely copy-pasted from the CAP-SASL plugin */ + passlen = strlen (user) * 2 + 2 + strlen (pass); + buffer = (char*) malloc (passlen + 1); + strcpy (buffer, user); + strcpy (buffer + strlen (user) + 1, user); + strcpy (buffer + strlen (user) * 2 + 2, pass); + encoded = g_base64_encode ((unsigned char*) buffer, passlen); + + free (buffer); + + return encoded; +} |