mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
viml: re-add sha256() function
Was removed in #699 but actually doesn't have anything to do with security.
This commit is contained in:
parent
845d1bfa90
commit
6cbda2cbf6
@ -6490,6 +6490,7 @@ static struct fst {
|
||||
{"settabvar", 3, 3, f_settabvar},
|
||||
{"settabwinvar", 4, 4, f_settabwinvar},
|
||||
{"setwinvar", 3, 3, f_setwinvar},
|
||||
{"sha256", 1, 1, f_sha256},
|
||||
{"shellescape", 1, 2, f_shellescape},
|
||||
{"shiftwidth", 0, 0, f_shiftwidth},
|
||||
{"simplify", 1, 1, f_simplify},
|
||||
@ -13102,6 +13103,17 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off)
|
||||
}
|
||||
}
|
||||
|
||||
/// f_sha256 - sha256({string}) function
|
||||
static void f_sha256(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u *p = get_tv_string(&argvars[0]);
|
||||
const char_u *hash = sha256_bytes(p, (int) STRLEN(p) , NULL, 0);
|
||||
|
||||
// make a copy of the hash (sha256_bytes returns a static buffer)
|
||||
rettv->vval.v_string = (char_u *) xstrdup((char *) hash);
|
||||
rettv->v_type = VAR_STRING;
|
||||
}
|
||||
|
||||
/*
|
||||
* "shellescape({string})" function
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user