original) (raw)
PostgreSQL Source Code: src/test/modules/ldap_password_func/ldap_password_func.c File Reference (#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include <[float.h](float%5F8h%5Fsource.html)>
#include <stdio.h>
#include "[fmgr.h](fmgr%5F8h%5Fsource.html)"
#include "[libpq/auth.h](auth%5F8h%5Fsource.html)"
Go to the source code of this file.
◆ _PG_init()
◆ rot13_passphrase()
static char * rot13_passphrase ( char * password) | static |
---|
Definition at line 38 of file ldap_password_func.c.
39{
40 size_t size = strlen(pw) + 1;
41
42 char *new_pw = (char *) palloc(size);
43
44 strlcpy(new_pw, pw, size);
45 for (char *p = new_pw; *p; p++)
46 {
47 char c = *p;
48
49 if ((c >= 'a' && c <= 'm') || (c >= 'A' && c <= 'M'))
50 *p = c + 13;
51 else if ((c >= 'n' && c <= 'z') || (c >= 'N' && c <= 'Z'))
52 *p = c - 13;
53 }
54
55 return new_pw;
56}
size_t strlcpy(char *dst, const char *src, size_t siz)
References palloc(), and strlcpy().
Referenced by _PG_init().