shkwon98 / pwgen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pwgen - C++ Password Generation Library

Table of Contents

About

Pwgen is an open-source C++ library that generates passwords with a length of 8 base64 characters. It is meant to be a simple and easy-to-use library that can be used in any C++ project that requires password generation.

Getting Started

This section describes how to add pwgen as a dependency to your C++ project. While Pwgen has dependency on the Crypto++ library, it is not necessary to install it separately as it will be built along with pwgen. Pwgen supports CMake, so you can easily add it to your project by following the instructions below.

find_package (Not supported yet)

The canonical way to discover dependencies in CMake is the find_package command. This way will be supported soon.

find_package(pwgen CONFIG REQUIRED)
add_executable(my_exe my_exe.cpp)
target_link_libraries(my_exe pwgen::pwgen)

find_package can only find software that has already been installed on your system. In practice that means you'll need to install pwgen using cmake first. Pwgen's cmake support will provide the option to install pwgen either system-wide(not recommended) or under a directory prefix in a way that you can later easily use it with the find_package(pwgen CONFIG REQUIRED) command.

The following sections describe strategies to automatically build pwgen as part of your project.

FetchContent

If you are using CMake v3.11 or newer you'd better use CMake's FetchContent module. The first time you run CMake in a given build directory, FetchContent will clone the pwgen repository. FetchContent_MakeAvailable() also sets up an add_subdirectory() rule for you. This causes pwgen to be built as part of your project.

cmake_minimum_required(VERSION 3.11)
project(my_project)

include(FetchContent)
FetchContent_Declare(
  pwgen
  GIT_REPOSITORY https://github.com/shkwon98/pwgen)
set(FETCHCONTENT_QUIET OFF)
FetchContent_MakeAvailable(pwgen)

add_executable(my_exe my_exe.cpp)
target_link_libraries(my_exe pwgen::pwgen)

git submodule

If you cannot use FetchContent, another approach is to add the pwgen source tree to your project as a git submodule. You can then add it to your CMake project with add_subdirectory().

add_subdirectory(pwgen)
add_executable(my_exe my_exe.cpp)
target_link_libraries(my_exe pwgen::pwgen)

Installing

If you want to install pwgen library, you can use the following methods.

Build from source

You can build and install pwgen from source by following the instructions below.

git clone https://github.com/shkwon98/pwgen.git
cd pwgen

System-wide installation

cmake -S . -B build
cmake --build build
cmmake --install build

Local installation

cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<path_to_install>
cmake --build build
cmmake --install build

Package manager (Not supported yet)

Pwgen might be available in package managers like vcpkg or conan in the future.

Usage

You can find out how to use the pwgen library by looking at the example codes. Some simple c++ example codes are provided in the examples directory to show how to use the pwgen library.

About

License:BSD 2-Clause "Simplified" License


Languages

Language:C++ 89.0%Language:CMake 11.0%