diff -r 30b3b1da0350 runtime/doc/eval.txt
--- a/runtime/doc/eval.txt	Thu Jan 31 21:09:15 2013 +0100
+++ b/runtime/doc/eval.txt	Tue Feb 05 20:16:23 2013 +0900
@@ -1931,6 +1931,7 @@
 settabwinvar( {tabnr}, {winnr}, {varname}, {val})    set {varname} in window
 					{winnr} in tab page {tabnr} to {val}
 setwinvar( {nr}, {varname}, {val})	set {varname} in window {nr} to {val}
+sha256( {string})		String	SHA256 checksum of {string}
 shellescape( {string} [, {special}])
 				String	escape {string} for use as shell
 					command argument
@@ -5336,6 +5337,10 @@
 			:call setwinvar(1, "&list", 0)
 			:call setwinvar(2, "myvar", "foobar")
 
+sha256({string})							*sha256()*
+		Returns a String, which is SHA256 checksum of {string}.
+		{only available when compiled with the |+cryptv| feature}
+
 shellescape({string} [, {special}])			*shellescape()*
 		Escape {string} for use as a shell command argument.
 		On MS-Windows and MS-DOS, when 'shellslash' is not set, it
diff -r 30b3b1da0350 src/eval.c
--- a/src/eval.c	Thu Jan 31 21:09:15 2013 +0100
+++ b/src/eval.c	Tue Feb 05 20:16:23 2013 +0900
@@ -688,6 +688,9 @@
 static void f_settabvar __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
+#ifdef FEAT_CRYPT
+static void f_sha256 __ARGS((typval_T *argvars, typval_T *rettv));
+#endif /* FEAT_CRYPT */
 static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_shiftwidth __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
@@ -8055,6 +8058,9 @@
     {"settabvar",	3, 3, f_settabvar},
     {"settabwinvar",	4, 4, f_settabwinvar},
     {"setwinvar",	3, 3, f_setwinvar},
+#ifdef FEAT_CRYPT
+    {"sha256",		1, 1, f_sha256},
+#endif
     {"shellescape",	1, 2, f_shellescape},
     {"shiftwidth",	0, 0, f_shiftwidth},
     {"simplify",	1, 1, f_simplify},
@@ -16710,6 +16716,25 @@
     }
 }
 
+#ifdef FEAT_CRYPT
+/*
+ * "sha256({string})" function
+ */
+    static void
+f_sha256(argvars, rettv)
+    typval_T	*argvars;
+    typval_T	*rettv;
+{
+    char_u	*p;
+
+    p = get_tv_string(&argvars[0]);
+    rettv->vval.v_string = sha256_bytes(
+	p, (int)STRLEN(p), NULL, 0);
+    rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
+    rettv->v_type = VAR_STRING;
+}
+#endif /* FEAT_CRYPT */
+
 /*
  * "shellescape({string})" function
  */
diff -r 30b3b1da0350 src/proto/sha256.pro
--- a/src/proto/sha256.pro	Thu Jan 31 21:09:15 2013 +0100
+++ b/src/proto/sha256.pro	Tue Feb 05 20:16:23 2013 +0900
@@ -5,4 +5,5 @@
 char_u *sha256_key __ARGS((char_u *buf, char_u *salt, int salt_len));
 int sha256_self_test __ARGS((void));
 void sha2_seed __ARGS((char_u *header, int header_len, char_u *salt, int salt_len));
+char_u *sha256_bytes __ARGS((char_u *buf, int buf_len, char_u *salt, int salt_len));
 /* vim: set ft=c : */
diff -r 30b3b1da0350 src/sha256.c
--- a/src/sha256.c	Thu Jan 31 21:09:15 2013 +0100
+++ b/src/sha256.c	Tue Feb 05 20:16:23 2013 +0900
@@ -273,14 +273,14 @@
 #endif /* FEAT_CRYPT || FEAT_PERSISTENT_UNDO */
 
 #if defined(FEAT_CRYPT) || defined(PROTO)
-static char_u *sha256_bytes __ARGS((char_u *buf, int buf_len, char_u *salt, int salt_len));
+char_u *sha256_bytes __ARGS((char_u *buf, int buf_len, char_u *salt, int salt_len));
 static unsigned int get_some_time __ARGS((void));
 
 /*
  * Returns hex digest of "buf[buf_len]" in a static array.
  * if "salt" is not NULL also do "salt[salt_len]".
  */
-    static char_u *
+    char_u *
 sha256_bytes(buf, buf_len, salt, salt_len)
     char_u *buf;
     int    buf_len;
diff -r 30b3b1da0350 src/testdir/Makefile
--- a/src/testdir/Makefile	Thu Jan 31 21:09:15 2013 +0100
+++ b/src/testdir/Makefile	Tue Feb 05 20:16:23 2013 +0900
@@ -27,7 +27,8 @@
 		test69.out test70.out test71.out test72.out test73.out \
 		test74.out test75.out test76.out test77.out test78.out \
 		test79.out test80.out test81.out test82.out test83.out \
-		test84.out test85.out test86.out test87.out test88.out
+		test84.out test85.out test86.out test87.out test88.out \
+		test89.out
 
 SCRIPTS_GUI = test16.out
 
diff -r 30b3b1da0350 src/testdir/test89.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test89.in	Tue Feb 05 20:16:23 2013 +0900
@@ -0,0 +1,53 @@
+Tests for sha256() function.    vim: set ft=vim et ts=2 sw=2 :
+
+STARTTEST
+:so small.vim
+:if !has('cryptv') || !exists('*sha256')
+   e! test.ok
+   wq! test.out
+:endif
+:"
+:let testcase='test for empty string: '
+:if sha256("") ==# 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
+: let res='ok'
+:else
+: let res='ng'
+:endif
+:$put =testcase.res
+:"
+:let testcase='test for 1 char: '
+:if sha256("a") ==# 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb'
+: let res='ok'
+:else
+: let res='ng'
+:endif
+:$put =testcase.res
+:"
+:let testcase='test for 3 chars: '
+:if sha256("abc") ==# 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
+: let res='ok'
+:else
+: let res='ng'
+:endif
+:$put =testcase.res
+:"
+:let testcase='test for contains meta char: '
+:if sha256("foo\nbar") ==# '807eff6267f3f926a21d234f7b0cf867a86f47e07a532f15e8cc39ed110ca776'
+: let res='ok'
+:else
+: let res='ng'
+:endif
+:$put =testcase.res
+:"
+:let testcase='test for contains non-ascii char: '
+:if sha256("\xde\xad\xbe\xef") ==# '5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953'
+: let res='ok'
+:else
+: let res='ng'
+:endif
+:$put =testcase.res
+"
+:/^start:/,$wq! test.out
+ENDTEST
+
+start:
diff -r 30b3b1da0350 src/testdir/test89.ok
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test89.ok	Tue Feb 05 20:16:23 2013 +0900
@@ -0,0 +1,6 @@
+start:
+test for empty string: ok
+test for 1 char: ok
+test for 3 chars: ok
+test for contains meta char: ok
+test for contains non-ascii char: ok