Compare commits
No commits in common. "master" and "circleci-project-setup" have entirely different histories.
master
...
circleci-p
13
.circleci/config.yml
Normal file
13
.circleci/config.yml
Normal file
@ -0,0 +1,13 @@
|
||||
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
|
||||
version: 2.1
|
||||
# Use a package of configuration called an orb.
|
||||
orbs:
|
||||
# Declare a dependency on the welcome-orb
|
||||
welcome: circleci/welcome-orb@0.4.1
|
||||
# Orchestrate or schedule a set of jobs
|
||||
workflows:
|
||||
# Name the workflow "welcome"
|
||||
welcome:
|
||||
# Run the welcome/run job in its own container
|
||||
jobs:
|
||||
- welcome/run
|
@ -12,20 +12,11 @@ jobs:
|
||||
# well on Windows or Mac. You can convert this to a matrix build if you need
|
||||
# cross-platform coverage.
|
||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||
runs-on: ubuntu-gitea
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: Prep For Local Builds
|
||||
run: echo "${LOCIP} gitea.comnenos" >> /etc/hosts
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install Build Tools
|
||||
run: |
|
||||
apt update
|
||||
apt -y --no-install-recommends install build-essential clang cmake gdb git wget
|
||||
|
||||
- name: Create Build Environment
|
||||
# Some projects don't allow in-source building, so create a separate build directory
|
||||
# We'll use this as our working directory for all subsequent commands
|
@ -3,4 +3,4 @@ project(passwdgen)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
add_executable(passwdgen passwdgen.cpp)
|
||||
add_executable(passwdgen main.cpp)
|
22
README.md
22
README.md
@ -1,22 +0,0 @@
|
||||
# passwdgen
|
||||
### a rudimentary random string password generator
|
||||
|
||||
For demo purposes only
|
||||
|
||||
## Build
|
||||
|
||||
**Bare Bones**
|
||||
```bash
|
||||
mkdir build
|
||||
g++ -o build/passwdgen ./passwdgen.cpp
|
||||
```
|
||||
|
||||
**From CMAKE**
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
Then, just copy the compiled binary to somewhere on your $PATH
|
BIN
bin/linux/passwdgen
Executable file
BIN
bin/linux/passwdgen
Executable file
Binary file not shown.
BIN
bin/osx/passwdgen
Executable file
BIN
bin/osx/passwdgen
Executable file
Binary file not shown.
@ -1,12 +1,6 @@
|
||||
//
|
||||
// passwdgen.cpp
|
||||
// Created by Greg Gauthier on 2020.10.22.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
|
||||
|
||||
std::string random_string(std::size_t length, bool punc) {
|
||||
std::string CHARACTERS;
|
||||
std::string ALPHANUM = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
@ -19,7 +13,7 @@ std::string random_string(std::size_t length, bool punc) {
|
||||
}
|
||||
std::random_device random_device;
|
||||
std::mt19937 generator(random_device());
|
||||
std::uniform_int_distribution<> distribution(0.0, CHARACTERS.size() - 1.0);
|
||||
std::uniform_int_distribution<> distribution(0, CHARACTERS.size() - 1);
|
||||
|
||||
std::string random_string;
|
||||
for (std::size_t i = 0; i < length; ++i) {
|
||||
@ -31,15 +25,15 @@ std::string random_string(std::size_t length, bool punc) {
|
||||
void show_usage(std::string binname) {
|
||||
std::cerr << "Usage: " << binname << " [OPTIONS] " << std::endl
|
||||
<< "Options:" << std::endl
|
||||
<< "\t-h, --help \t\tShow this help message" << std::endl
|
||||
<< "\t-l, --length [n] \t\tThe length of the password (default: 32)" << std::endl
|
||||
<< "\t-h, --help \t\tShow this help message" << std::endl
|
||||
<< "\t-l, --length \t\tThe length of the password (default: 32)" << std::endl
|
||||
<< "\t-p, --punctuation \t\tToggle special characters (default: false)"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string passlenstr;
|
||||
int passlen = 0;
|
||||
int passlen;
|
||||
bool punc = false;
|
||||
|
||||
if (argc < 1) {
|
||||
@ -54,24 +48,18 @@ int main(int argc, char *argv[]) {
|
||||
} else if (arg == "-p") {
|
||||
punc = true;
|
||||
} else if ((arg == "-l") || (arg == "--length")) {
|
||||
if (not argv[i +1]) {
|
||||
std::cerr << "Specify a password length" << std::endl;
|
||||
passlenstr = argv[i + 1];
|
||||
if (passlenstr.empty()) {
|
||||
std::cerr << "--destination option requires one argument." << std::endl;
|
||||
return 1;
|
||||
} else {
|
||||
passlenstr = argv[i + 1];
|
||||
try {
|
||||
passlen = std::stoi(passlenstr);
|
||||
} catch (const std::invalid_argument& e){
|
||||
std::cerr << "Length must be a valid integer" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (passlen == 0) {
|
||||
passlen = 32;
|
||||
if (passlenstr.empty()) {
|
||||
passlenstr = "32";
|
||||
}
|
||||
passlen = std::stoi(passlenstr);
|
||||
std::string password = random_string(passlen, punc);
|
||||
std::cout << password << std::endl;
|
||||
return 0;
|
Loading…
Reference in New Issue
Block a user