diff options
author | Nicolas Hillegeer <nicolas@hillegeer.com> | 2014-07-21 19:10:49 +0200 |
---|---|---|
committer | Nicolas Hillegeer <nicolas@hillegeer.com> | 2014-07-21 19:29:29 +0200 |
commit | 6cbda2cbf606aafe7a014ab66175048aea9da03e (patch) | |
tree | 9c5e23fdefbe48e8585a19b54b6ea5b39b267dd9 | |
parent | 845d1bfa905cf0d28d9a1a662e42525449dd1be4 (diff) | |
download | rneovim-6cbda2cbf606aafe7a014ab66175048aea9da03e.tar.gz rneovim-6cbda2cbf606aafe7a014ab66175048aea9da03e.tar.bz2 rneovim-6cbda2cbf606aafe7a014ab66175048aea9da03e.zip |
viml: re-add sha256() function
Was removed in #699 but actually doesn't have anything to do with security.
-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 */ |