Compile to .exe
This commit is contained in:
parent
7704d049ab
commit
1d19ad496f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
*.o
|
||||
*.exe
|
||||
passgen
|
||||
.cache/
|
||||
|
27
Makefile
27
Makefile
@ -1,13 +1,34 @@
|
||||
TARGETS = passgen
|
||||
BINARYOUT_TARGETS = passgen.o
|
||||
|
||||
CPPFLAGS += -I./include
|
||||
CXXFLAGS += -std=c++20 -O2
|
||||
CC = $(CXX) # Cheat so that linking uses the C++ compiler
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
CC = x86_64-w64-mingw32-g++
|
||||
LD = x86_64-w64-mingw32-g++
|
||||
EXE_EXT = .exe
|
||||
else
|
||||
CC = g++
|
||||
LD = g++
|
||||
EXE_EXT =
|
||||
endif
|
||||
|
||||
all: $(TARGETS)$(EXE_EXT)
|
||||
|
||||
run:
|
||||
./passgen$(EXE_EXT)
|
||||
|
||||
clean:
|
||||
rm -f *.o $(TARGETS) $(BINARYOUT_TARGETS)
|
||||
rm -f *.o *.exe $(TARGETS) $(BINARYOUT_TARGETS)
|
||||
|
||||
passgen.exe: passgen.o
|
||||
$(LD) -static-libgcc -static-libstdc++ passgen.o -o passgen.exe
|
||||
|
||||
passgen: passgen.o
|
||||
$(LD) passgen.o -o passgen
|
||||
|
||||
passgen.o: passgen.cpp ./include/pcg_random.hpp \
|
||||
./include/pcg_extras.hpp ./include/pcg_uint128.hpp
|
||||
$(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o passgen.o passgen.cpp
|
||||
|
23
passgen.cpp
23
passgen.cpp
@ -1,6 +1,7 @@
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -25,13 +26,16 @@ std::vector<std::string> readWordlist(std::string filePath)
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string path;
|
||||
int count;
|
||||
|
||||
if (argc == 2) {
|
||||
if (argc == 3) {
|
||||
path = argv[1];
|
||||
count = atoi(argv[2]);
|
||||
} else if (argc == 1) {
|
||||
path = "eff_large_wordlist.txt";
|
||||
count = 5;
|
||||
} else {
|
||||
std::cout << "usage: passgen <wordlist_path>\n";
|
||||
std::cout << "usage: passgen <wordlist_path> <wordcount>\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -41,5 +45,18 @@ int main(int argc, char *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << wordlist[0] << "\n";
|
||||
for (int i = 0; i < count; i++) {
|
||||
pcg_extras::seed_seq_from<std::random_device> seed_source;
|
||||
pcg32 rng(seed_source);
|
||||
|
||||
int random_int = std::uniform_int_distribution<int>(0, wordlist.size())(rng);
|
||||
|
||||
std::cout << wordlist[random_int];
|
||||
|
||||
if (i+1 == count) {
|
||||
std::cout << "\n";
|
||||
} else {
|
||||
std::cout << "-";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user