diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 77f327c124..069715ffee 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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 */ |