pike.git/
src/
builtin_functions.c
Branch:
Tag:
Non-build tags
All tags
No tags
2016-12-08
2016-12-08 18:20:31 by Martin Nilsson <nilsson@fastmail.com>
aa5f9962a304dbae572c97f3f7c0b1e1a512be24 (
18
lines) (+
16
/-
2
)
[
Show
|
Annotate
]
Branch:
8.1
Calling crypt() now crypts a random string. Useful as a quick way of generating passwords.
3207:
/*! @decl string(46..122) crypt(string(1..255) password) *! @decl int(0..1) crypt(string(1..255) input_password, @ *! string(46..122) crypted_password)
+
*! @decl string(46..122) crypt()
*! *! This function crypts and verifies a short string (only the first *! 8 characters are significant).
3218:
*! @[crypted_password], and returns @expr{1@} if they match, and *! @expr{0@} (zero) otherwise. *!
+
*! The third syntax generates a random string and then crypts it,
+
*! creating a string useful as a password.
+
*!
*! @note *! Note that strings containing null characters will only be *! processed up until the null character.
3229:
char *alphabet = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
get_all_args("crypt", args, "%s
.
%s", &pwd, &saltp);
+
get_all_args("crypt", args, "
.
%s%s", &pwd, &saltp);
-
+
if( !pwd )
+
{
+
do {
+
push_random_string(16);
+
push_constant_text("\0");
+
f_minus(2);
+
} while(Pike_sp[-1].u.string->len<8);
+
}
+
if(saltp) { if( Pike_sp[1-args].u.string->len < 2 )
9405:
/* function(string:string)|function(string,string:int) */ ADD_EFUN("crypt",f_crypt,
-
tOr(tFunc(tStr,tStr7),tFunc(tStr tStr,tInt01)),OPT_EXTERNAL_DEPEND);
+
tOr(tFunc(
tOr(
tStr,
tVoid),
tStr7),tFunc(tStr tStr,tInt01)),OPT_EXTERNAL_DEPEND);
/* function(object|void:void) */ ADD_EFUN("destruct",f_destruct,tFunc(tOr(tObj,tVoid),tVoid),OPT_SIDE_EFFECT);