Skip to content

Commit ba0f0cb

Browse files
committed
add sha512
1 parent 3c042e6 commit ba0f0cb

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ add_test(dijkstra_optimize_fastio dijkstra_optimize_fastio)
3636
add_executable(dijkstra_optimize_fastio_unchecked src/0004.dijkstra/dijkstra_optimize_fastio_unchecked.cc)
3737
add_test(dijkstra_optimize_fastio_unchecked dijkstra_optimize_fastio_unchecked)
3838

39+
add_executable(sha512 src/0005.sha/sha512.cc)
40+
add_test(sha512 sha512)
41+
3942
add_executable(vector_push_back src/0006.vector_push_back/vector_push_back.cc)
40-
add_test(vector_push_back vector_push_back)
43+
add_test(vector_push_back vector_push_back)
44+

src/0005.sha/sha512.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <fast_io_dsal/vector.h>
2+
#include <fast_io.h>
3+
#include <fast_io_device.h>
4+
#include <fast_io_crypto.h>
5+
6+
int main(int argc, char **argv)
7+
{
8+
using namespace fast_io::mnp;
9+
::fast_io::vector<::std::size_t> vec(10000000,5);
10+
{
11+
auto t0{fast_io::posix_clock_gettime(fast_io::posix_clock_id::realtime)};
12+
fast_io::sha512_context ctx;
13+
::fast_io::operations::write_all_range(as_file(ctx),vec);
14+
ctx.do_final();
15+
println(hash_digest(ctx), " *", os_c_str(argv[1]), "\nElapsed Time:", fast_io::posix_clock_gettime(fast_io::posix_clock_id::realtime) - t0);
16+
}
17+
}
18+

0 commit comments

Comments
 (0)