Go to file
2023-11-05 14:46:03 +08:00
.idea init 2023-11-03 20:52:53 +08:00
.vscode init 2023-11-03 20:52:53 +08:00
data add word analyzer 2023-11-04 00:22:45 +08:00
.clang-format init 2023-11-03 20:52:53 +08:00
.gitignore stat_word: seq faster than par 2023-11-04 00:58:06 +08:00
analyzer.cpp add word analyzer 2023-11-04 00:22:45 +08:00
CMakeLists.txt add readme 2023-11-05 14:46:03 +08:00
defs.hpp add word analyzer 2023-11-04 00:22:45 +08:00
README.md add readme 2023-11-05 14:46:03 +08:00
stat_date.cpp add missing headers 2023-11-05 14:32:03 +08:00
stat_keystroke.cpp add missing headers 2023-11-05 14:32:03 +08:00
stat_length.cpp timeit 2023-11-04 00:24:22 +08:00
stat_struct.cpp timeit 2023-11-04 00:24:22 +08:00
stat_word.cpp add missing headers 2023-11-05 14:32:03 +08:00
tests.cpp add test and analyzer 2023-11-03 21:12:25 +08:00
utils.cpp add word analyzer 2023-11-04 00:22:45 +08:00

password-analyzer

Description

实现了以下的分析功能:

Compile and Run

Prerequisites

项目使用了 C++23 标准进行编写,需要使用支持 C++23 的编译器进行编译

经过测试的编译器:

# g++ -v                          
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20230801 (GCC)

如果使用 clang++ 编译器,需要修改 CMakeLists.txt,强制使用 libc++patch 如下:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ca65a4..5129602 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,6 +12,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=mold -Wno-unused-command-line-argument")
 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address,undefined")
 
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
+gset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+
 message(STATUS "[DEPS] Processing spdlog")
 FetchContent_Declare(
         spdlog

其它依赖:

  1. cmake >= 3.12
  2. make or ninja
  3. git
  4. mold: 可选,若不需要使用 mold 进行链接,请在 CMakeLists.txt 中删除 -fuse-ld=mold 选项

Compile

编译:

mkdir build

pushd
cmake ..
cmake --build . -j
popd

Run

项目根目录 下运行:

# ./build/password-analyzer
[2023-11-05 14:45:17.980] [info] [stat_length(YAHOO)] start...
[2023-11-05 14:45:18.174] [info] 8: 119134
[2023-11-05 14:45:18.174] [info] 6: 79628
[2023-11-05 14:45:18.174] [info] 9: 65963
...