Move SASL passphrase generation code to utils

This commit is contained in:
Berke Viktor
2012-10-25 21:08:26 +02:00
parent f50a1bf1dd
commit 215325c058
3 changed files with 25 additions and 17 deletions

View File

@@ -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;
}