mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 14:57:09 -05:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
5d3b6953af
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,4 +10,5 @@ release*/
|
|||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.version
|
.version
|
||||||
|
\.scannerwork/
|
||||||
|
@ -339,6 +339,8 @@ if(ZLIB_VERSION_STRING VERSION_LESS "1.2.0")
|
|||||||
message(FATAL_ERROR "zlib 1.2.0 or higher is required to use the gzip format")
|
message(FATAL_ERROR "zlib 1.2.0 or higher is required to use the gzip format")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include_directories(SYSTEM ${ARGON2_INCLUDE_DIR})
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
if(WITH_XC_YUBIKEY)
|
if(WITH_XC_YUBIKEY)
|
||||||
find_package(YubiKey REQUIRED)
|
find_package(YubiKey REQUIRED)
|
||||||
|
4
COPYING
4
COPYING
@ -235,3 +235,7 @@ License: LGPL-2.1
|
|||||||
Files: share/macosx/dmg-background.tiff
|
Files: share/macosx/dmg-background.tiff
|
||||||
Copyright: 2008-2014, Andrey Tarantsov
|
Copyright: 2008-2014, Andrey Tarantsov
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
||||||
|
Files: cmake/DeployQt.cmake
|
||||||
|
Copyright: 2018, Nathan Osman
|
||||||
|
License: MIT
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# <img src="https://keepassxc.org/logo.png" width="40" height="40"/> KeePassXC
|
# <img src="https://keepassxc.org/logo.png" width="40" height="40"/> KeePassXC
|
||||||
[![TeamCity Build Status](https://ci.keepassxc.org/app/rest/builds/buildType:\(id:KeepassXC_TeamCityCi\)/statusIcon?guest=1)](https://ci.keepassxc.org/viewType.html?buildTypeId=KeepassXC_TeamCityCi&guest=1) [![Coverage Status](https://coveralls.io/repos/github/keepassxreboot/keepassxc/badge.svg)](https://coveralls.io/github/keepassxreboot/keepassxc)
|
[![TeamCity Build Status](https://ci.keepassxc.org/app/rest/builds/buildType:\(id:KeepassXC_TeamCityCi\)/statusIcon?guest=1)](https://ci.keepassxc.org/viewType.html?buildTypeId=KeepassXC_TeamCityCi&guest=1) [![Build status](https://ci.appveyor.com/api/projects/status/qmcar8rnqjh4oxof?svg=true)](https://ci.appveyor.com/project/droidmonkey/keepassxc) [![codecov](https://codecov.io/gh/keepassxreboot/keepassxc/branch/develop/graph/badge.svg)](https://codecov.io/gh/keepassxreboot/keepassxc)
|
||||||
|
|
||||||
|
|
||||||
## About KeePassXC
|
## About KeePassXC
|
||||||
[KeePassXC](https://keepassxc.org) is a cross-platform community fork of
|
[KeePassXC](https://keepassxc.org) is a cross-platform community fork of
|
||||||
@ -32,7 +33,7 @@ so please check out your distribution's package list to see if KeePassXC is avai
|
|||||||
- Browser integration with KeePassHTTP-Connector for
|
- Browser integration with KeePassHTTP-Connector for
|
||||||
[Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepasshttp-connector/) and
|
[Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepasshttp-connector/) and
|
||||||
[Google Chrome or Chromium](https://chrome.google.com/webstore/detail/keepasshttp-connector/dafgdjggglmmknipkhngniifhplpcldb), and
|
[Google Chrome or Chromium](https://chrome.google.com/webstore/detail/keepasshttp-connector/dafgdjggglmmknipkhngniifhplpcldb), and
|
||||||
[passafari](https://github.com/mmichaa/passafari.safariextension/) in Safari. [[See note about KeePassHTTP]](#Note_about_KeePassHTTP)
|
[passafari](https://github.com/mmichaa/passafari.safariextension/) in Safari. [[See note about KeePassHTTP]](#note-about-keepasshttp)
|
||||||
- Browser integration with KeePassXC-Browser using [native messaging](https://developer.chrome.com/extensions/nativeMessaging) for [Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) and [Google Chrome or Chromium](https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk)
|
- Browser integration with KeePassXC-Browser using [native messaging](https://developer.chrome.com/extensions/nativeMessaging) for [Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) and [Google Chrome or Chromium](https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk)
|
||||||
- Many bug fixes
|
- Many bug fixes
|
||||||
|
|
||||||
|
31
appveyor.yml
Normal file
31
appveyor.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
image:
|
||||||
|
- Visual Studio 2017
|
||||||
|
|
||||||
|
configuration:
|
||||||
|
- Debug
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- CC: gcc
|
||||||
|
CXX: g++
|
||||||
|
|
||||||
|
clone_depth: 1
|
||||||
|
|
||||||
|
platform:
|
||||||
|
- x64
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
|
||||||
|
install:
|
||||||
|
- C:\msys64\usr\bin\env MSYSTEM=MINGW64 /bin/bash -l -c "pacman --noconfirm -Syu"
|
||||||
|
- C:\msys64\usr\bin\env MSYSTEM=MINGW64 /bin/bash -l -c "/c/projects/keepassxc/ci/appveyor/install.sh"
|
||||||
|
|
||||||
|
before_build:
|
||||||
|
- C:\msys64\usr\bin\env MSYSTEM=MINGW64 /bin/bash -l -c "/c/projects/keepassxc/ci/appveyor/before-build.sh"
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- C:\msys64\usr\bin\env MSYSTEM=MINGW64 /bin/bash -l -c "/c/projects/keepassxc/ci/appveyor/build.sh"
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- C:\msys64\usr\bin\env MSYSTEM=MINGW64 /bin/bash -l -c "/c/projects/keepassxc/ci/appveyor/test.sh"
|
21
ci/appveyor/before-build.sh
Normal file
21
ci/appveyor/before-build.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
cd /c/projects/keepassxc
|
||||||
|
mkdir build && cd build
|
||||||
|
|
||||||
|
if [ "${configuration}" = "Debug" ]; then
|
||||||
|
cmake -G "MSYS Makefiles" \
|
||||||
|
-DCMAKE_BUILD_TYPE=${configuration} \
|
||||||
|
-DWITH_XC_ALL=ON \
|
||||||
|
-DWITH_TESTS=ON \
|
||||||
|
-DWITH_GUI_TESTS=ON \
|
||||||
|
-DWITH_ASAN=ON \
|
||||||
|
..
|
||||||
|
else
|
||||||
|
cmake -G "MSYS Makefiles" \
|
||||||
|
-DCMAKE_BUILD_TYPE=${configuration} \
|
||||||
|
-DWITH_XC_ALL=ON \
|
||||||
|
-DWITH_TESTS=ON \
|
||||||
|
-DWITH_GUI_TESTS=ON \
|
||||||
|
..
|
||||||
|
fi
|
5
ci/appveyor/build.sh
Normal file
5
ci/appveyor/build.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
cd /c/projects/keepassxc/build
|
||||||
|
|
||||||
|
make -j2
|
24
ci/appveyor/install.sh
Normal file
24
ci/appveyor/install.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# Pacman derived dependencies
|
||||||
|
pacman --needed --noconfirm -S \
|
||||||
|
mingw-w64-$(uname -m)-cmake \
|
||||||
|
mingw-w64-$(uname -m)-libgcrypt \
|
||||||
|
mingw-w64-$(uname -m)-zlib \
|
||||||
|
mingw-w64-$(uname -m)-libsodium \
|
||||||
|
mingw-w64-$(uname -m)-argon2 \
|
||||||
|
mingw-w64-$(uname -m)-qt5
|
||||||
|
|
||||||
|
# Yubikey library
|
||||||
|
curl -O -J -L https://developers.yubico.com/yubikey-personalization/Releases/ykpers-1.18.1-win64.zip
|
||||||
|
7z x ykpers-1.18.1-win64.zip -o"/mingw64/" -aoa
|
||||||
|
|
||||||
|
# qrencode library
|
||||||
|
curl -O -J -L https://fukuchi.org/works/qrencode/qrencode-4.0.0.tar.gz
|
||||||
|
tar -xf qrencode-4.0.0.tar.gz
|
||||||
|
|
||||||
|
cd qrencode-4.0.0
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake -G "MSYS Makefiles" -DBUILD_SHARED_LIBS=YES -DWITH_TOOLS=NO -DCMAKE_BUILD_TYPE=${configuration} ..
|
||||||
|
make -j2
|
||||||
|
make install PREFIX="/mingw64"
|
6
ci/appveyor/test.sh
Normal file
6
ci/appveyor/test.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
cd /c/projects/keepassxc/build
|
||||||
|
|
||||||
|
make test ARGS+="-E testgui --output-on-failure --verbose"
|
||||||
|
make test ARGS+="-R testgui --output-on-failure --verbose"
|
@ -131,6 +131,10 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
|
|||||||
ENDIF() # NOT GENHTML_PATH
|
ENDIF() # NOT GENHTML_PATH
|
||||||
|
|
||||||
SET(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info")
|
SET(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info")
|
||||||
|
IF(MINGW)
|
||||||
|
# Replace C:/ with /C for MINGW
|
||||||
|
STRING(REGEX REPLACE "^([a-zA-Z]):" "/\\1" coverage_info ${coverage_info})
|
||||||
|
ENDIF()
|
||||||
SET(coverage_cleaned "${coverage_info}.cleaned")
|
SET(coverage_cleaned "${coverage_info}.cleaned")
|
||||||
|
|
||||||
SEPARATE_ARGUMENTS(test_command UNIX_COMMAND "${_testrunner}")
|
SEPARATE_ARGUMENTS(test_command UNIX_COMMAND "${_testrunner}")
|
||||||
|
88
cmake/DeployQt.cmake
Normal file
88
cmake/DeployQt.cmake
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Nathan Osman
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
|
||||||
|
# Retrieve the absolute path to qmake and then use that path to find
|
||||||
|
# the windeployqt and macdeployqt binaries
|
||||||
|
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
|
||||||
|
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
|
||||||
|
|
||||||
|
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
|
||||||
|
if(WIN32 AND NOT WINDEPLOYQT_EXECUTABLE)
|
||||||
|
message(FATAL_ERROR "windeployqt not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")
|
||||||
|
if(APPLE AND NOT MACDEPLOYQT_EXECUTABLE)
|
||||||
|
message(FATAL_ERROR "macdeployqt not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Add commands that copy the required Qt files to the same directory as the
|
||||||
|
# target after being built as well as including them in final installation
|
||||||
|
function(windeployqt target)
|
||||||
|
|
||||||
|
# Run windeployqt immediately after build
|
||||||
|
add_custom_command(TARGET ${target} POST_BUILD
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E
|
||||||
|
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
|
||||||
|
--verbose 0
|
||||||
|
--no-compiler-runtime
|
||||||
|
--no-angle
|
||||||
|
--no-opengl-sw
|
||||||
|
\"$<TARGET_FILE:${target}>\"
|
||||||
|
COMMENT "Deploying Qt..."
|
||||||
|
)
|
||||||
|
|
||||||
|
# windeployqt doesn't work correctly with the system runtime libraries,
|
||||||
|
# so we fall back to one of CMake's own modules for copying them over
|
||||||
|
|
||||||
|
# Doing this with MSVC 2015 requires CMake 3.6+
|
||||||
|
if((MSVC_VERSION VERSION_EQUAL 1900 OR MSVC_VERSION VERSION_GREATER 1900)
|
||||||
|
AND CMAKE_VERSION VERSION_LESS "3.6")
|
||||||
|
message(WARNING "Deploying with MSVC 2015+ requires CMake 3.6+")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
|
||||||
|
include(InstallRequiredSystemLibraries)
|
||||||
|
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
|
||||||
|
get_filename_component(filename "${lib}" NAME)
|
||||||
|
add_custom_command(TARGET ${target} POST_BUILD
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E
|
||||||
|
copy_if_different "${lib}" \"$<TARGET_FILE_DIR:${target}>\"
|
||||||
|
COMMENT "Copying ${filename}..."
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Add commands that copy the required Qt files to the application bundle
|
||||||
|
# represented by the target.
|
||||||
|
function(macdeployqt target)
|
||||||
|
add_custom_command(TARGET ${target} POST_BUILD
|
||||||
|
COMMAND "${MACDEPLOYQT_EXECUTABLE}"
|
||||||
|
\"$<TARGET_FILE_DIR:${target}>/../..\"
|
||||||
|
-always-overwrite
|
||||||
|
COMMENT "Deploying Qt..."
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
mark_as_advanced(WINDEPLOYQT_EXECUTABLE MACDEPLOYQT_EXECUTABLE)
|
18
sonar-project.properties
Normal file
18
sonar-project.properties
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# https://about.sonarcloud.io/get-started/
|
||||||
|
# Run the SonarCloud tools with the follow parameters:
|
||||||
|
# Run in the cmake build directory after cmake: build-wrapper-[platform]-x86-64 --out-dir bw-output make clean all
|
||||||
|
# Run in the project root directory: sonar-scanner.bat -Dsonar.cfamily.build-wrapper-output=build/bw-output -Dsonar.cfamily.gcov.reportsPath=build -Dsonar.login=[AUTH_TOKEN]
|
||||||
|
|
||||||
|
# required metadata
|
||||||
|
sonar.projectKey=keepassxc
|
||||||
|
sonar.organization=droidmonkey-github
|
||||||
|
sonar.projectName=keepassxc
|
||||||
|
sonar.host.url=https://sonarcloud.io
|
||||||
|
|
||||||
|
# path to source directories (required)
|
||||||
|
sonar.sources=src
|
||||||
|
sonar.tests=tests
|
||||||
|
|
||||||
|
sonar.cfamily.threads=2
|
||||||
|
|
||||||
|
sonar.exclusions=**/zxcvbn/*
|
@ -313,11 +313,8 @@ if(APPLE AND WITH_APP_BUNDLE)
|
|||||||
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSXC_VERSION}")
|
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSXC_VERSION}")
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|
||||||
add_custom_command(TARGET ${PROGNAME}
|
include(DeployQt)
|
||||||
POST_BUILD
|
macdeployqt(${PROGNAME})
|
||||||
COMMAND ${MACDEPLOYQT_EXE} ${PROGNAME}.app
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
|
|
||||||
COMMENT "Deploying app bundle")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS ${PROGNAME}
|
install(TARGETS ${PROGNAME}
|
||||||
@ -378,8 +375,8 @@ if(MINGW)
|
|||||||
set(gp_tool \"objdump\")
|
set(gp_tool \"objdump\")
|
||||||
" COMPONENT Runtime)
|
" COMPONENT Runtime)
|
||||||
|
|
||||||
include(DeployQt4)
|
include(DeployQt)
|
||||||
install_qt4_executable(${PROGNAME}.exe)
|
windeployqt(${PROGNAME})
|
||||||
|
|
||||||
# install Qt5 plugins
|
# install Qt5 plugins
|
||||||
set(PLUGINS_DIR ${Qt5_PREFIX}/share/qt5/plugins)
|
set(PLUGINS_DIR ${Qt5_PREFIX}/share/qt5/plugins)
|
||||||
|
@ -756,9 +756,10 @@ bool AutoType::verifyAutoTypeSyntax(const QString& sequence)
|
|||||||
}
|
}
|
||||||
} else if (AutoType::checkHighRepetition(sequence)) {
|
} else if (AutoType::checkHighRepetition(sequence)) {
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
reply =
|
reply = QMessageBox::question(nullptr,
|
||||||
QMessageBox::question(nullptr, tr("Auto-Type"), tr("This Auto-Type command contains arguments which are "
|
tr("Auto-Type"),
|
||||||
"repeated very often. Do you really want to proceed?"));
|
tr("This Auto-Type command contains arguments which are "
|
||||||
|
"repeated very often. Do you really want to proceed?"));
|
||||||
|
|
||||||
if (reply == QMessageBox::No) {
|
if (reply == QMessageBox::No) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -11,10 +11,11 @@ set_target_properties(keepassx-autotype-cocoa PROPERTIES LINK_FLAGS "-framework
|
|||||||
target_link_libraries(keepassx-autotype-cocoa ${PROGNAME} Qt5::Core Qt5::Widgets)
|
target_link_libraries(keepassx-autotype-cocoa ${PROGNAME} Qt5::Core Qt5::Widgets)
|
||||||
|
|
||||||
if(WITH_APP_BUNDLE)
|
if(WITH_APP_BUNDLE)
|
||||||
|
include(DeployQt)
|
||||||
add_custom_command(TARGET keepassx-autotype-cocoa
|
add_custom_command(TARGET keepassx-autotype-cocoa
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libkeepassx-autotype-cocoa.so ${PLUGIN_INSTALL_DIR}
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libkeepassx-autotype-cocoa.so ${PLUGIN_INSTALL_DIR}
|
||||||
COMMAND ${MACDEPLOYQT_EXE} ${PROGNAME}.app -executable=${PLUGIN_INSTALL_DIR}/libkeepassx-autotype-cocoa.so -no-plugins
|
COMMAND ${MACDEPLOYQT_EXECUTABLE} ${PROGNAME}.app -executable=${PLUGIN_INSTALL_DIR}/libkeepassx-autotype-cocoa.so -no-plugins
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
|
||||||
COMMENT "Deploying autotype plugin")
|
COMMENT "Deploying autotype plugin")
|
||||||
else()
|
else()
|
||||||
|
@ -261,6 +261,66 @@ void BrowserSettings::setPasswordUseSpecial(bool useSpecial)
|
|||||||
config()->set("generator/SpecialChars", useSpecial);
|
config()->set("generator/SpecialChars", useSpecial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BrowserSettings::passwordUseBraces()
|
||||||
|
{
|
||||||
|
return config()->get("generator/Braces", PasswordGenerator::DefaultBraces).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setPasswordUseBraces(bool useBraces)
|
||||||
|
{
|
||||||
|
config()->set("generator/Braces", useBraces);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BrowserSettings::passwordUsePunctuation()
|
||||||
|
{
|
||||||
|
return config()->get("generator/Punctuation", PasswordGenerator::DefaultQuotes).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setPasswordUsePunctuation(bool usePunctuation)
|
||||||
|
{
|
||||||
|
config()->set("generator/Punctuation", usePunctuation);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BrowserSettings::passwordUseQuotes()
|
||||||
|
{
|
||||||
|
return config()->get("generator/Quotes", PasswordGenerator::DefaultQuotes).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setPasswordUseQuotes(bool useQuotes)
|
||||||
|
{
|
||||||
|
config()->set("generator/Quotes", useQuotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BrowserSettings::passwordUseDashes()
|
||||||
|
{
|
||||||
|
return config()->get("generator/Dashes", PasswordGenerator::DefaultDashes).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setPasswordUseDashes(bool useDashes)
|
||||||
|
{
|
||||||
|
config()->set("generator/Dashes", useDashes);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BrowserSettings::passwordUseMath()
|
||||||
|
{
|
||||||
|
return config()->get("generator/Math", PasswordGenerator::DefaultMath).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setPasswordUseMath(bool useMath)
|
||||||
|
{
|
||||||
|
config()->set("generator/Math", useMath);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BrowserSettings::passwordUseLogograms()
|
||||||
|
{
|
||||||
|
return config()->get("generator/Logograms", PasswordGenerator::DefaultLogograms).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setPasswordUseLogograms(bool useLogograms)
|
||||||
|
{
|
||||||
|
config()->set("generator/Logograms", useLogograms);
|
||||||
|
}
|
||||||
|
|
||||||
bool BrowserSettings::passwordUseEASCII()
|
bool BrowserSettings::passwordUseEASCII()
|
||||||
{
|
{
|
||||||
return config()->get("generator/EASCII", PasswordGenerator::DefaultEASCII).toBool();
|
return config()->get("generator/EASCII", PasswordGenerator::DefaultEASCII).toBool();
|
||||||
@ -271,6 +331,26 @@ void BrowserSettings::setPasswordUseEASCII(bool useEASCII)
|
|||||||
config()->set("generator/EASCII", useEASCII);
|
config()->set("generator/EASCII", useEASCII);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BrowserSettings::advancedMode()
|
||||||
|
{
|
||||||
|
return config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setAdvancedMode(bool advancedMode)
|
||||||
|
{
|
||||||
|
config()->set("generator/AdvancedMode", advancedMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BrowserSettings::passwordExcludedChars()
|
||||||
|
{
|
||||||
|
return config()->get("generator/ExcludedChars", PasswordGenerator::DefaultExcludedChars).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserSettings::setPasswordExcludedChars(QString chars)
|
||||||
|
{
|
||||||
|
config()->set("generator/ExcludedChars", chars);
|
||||||
|
}
|
||||||
|
|
||||||
int BrowserSettings::passPhraseWordCount()
|
int BrowserSettings::passPhraseWordCount()
|
||||||
{
|
{
|
||||||
return config()->get("generator/WordCount", PassphraseGenerator::DefaultWordCount).toInt();
|
return config()->get("generator/WordCount", PassphraseGenerator::DefaultWordCount).toInt();
|
||||||
@ -347,6 +427,24 @@ PasswordGenerator::CharClasses BrowserSettings::passwordCharClasses()
|
|||||||
if (passwordUseSpecial()) {
|
if (passwordUseSpecial()) {
|
||||||
classes |= PasswordGenerator::SpecialCharacters;
|
classes |= PasswordGenerator::SpecialCharacters;
|
||||||
}
|
}
|
||||||
|
if (passwordUseBraces()) {
|
||||||
|
classes |= PasswordGenerator::Braces;
|
||||||
|
}
|
||||||
|
if (passwordUsePunctuation()) {
|
||||||
|
classes |= PasswordGenerator::Punctuation;
|
||||||
|
}
|
||||||
|
if (passwordUseQuotes()) {
|
||||||
|
classes |= PasswordGenerator::Quotes;
|
||||||
|
}
|
||||||
|
if (passwordUseDashes()) {
|
||||||
|
classes |= PasswordGenerator::Dashes;
|
||||||
|
}
|
||||||
|
if (passwordUseMath()) {
|
||||||
|
classes |= PasswordGenerator::Math;
|
||||||
|
}
|
||||||
|
if (passwordUseLogograms()) {
|
||||||
|
classes |= PasswordGenerator::Logograms;
|
||||||
|
}
|
||||||
if (passwordUseEASCII()) {
|
if (passwordUseEASCII()) {
|
||||||
classes |= PasswordGenerator::EASCII;
|
classes |= PasswordGenerator::EASCII;
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,24 @@ public:
|
|||||||
static void setPasswordUseUppercase(bool useUppercase);
|
static void setPasswordUseUppercase(bool useUppercase);
|
||||||
static bool passwordUseSpecial();
|
static bool passwordUseSpecial();
|
||||||
static void setPasswordUseSpecial(bool useSpecial);
|
static void setPasswordUseSpecial(bool useSpecial);
|
||||||
|
static bool passwordUseBraces();
|
||||||
|
static void setPasswordUseBraces(bool useBraces);
|
||||||
|
static bool passwordUsePunctuation();
|
||||||
|
static void setPasswordUsePunctuation(bool usePunctuation);
|
||||||
|
static bool passwordUseQuotes();
|
||||||
|
static void setPasswordUseQuotes(bool useQuotes);
|
||||||
|
static bool passwordUseDashes();
|
||||||
|
static void setPasswordUseDashes(bool useDashes);
|
||||||
|
static bool passwordUseMath();
|
||||||
|
static void setPasswordUseMath(bool useMath);
|
||||||
|
static bool passwordUseLogograms();
|
||||||
|
static void setPasswordUseLogograms(bool useLogograms);
|
||||||
static bool passwordUseEASCII();
|
static bool passwordUseEASCII();
|
||||||
static void setPasswordUseEASCII(bool useEASCII);
|
static void setPasswordUseEASCII(bool useEASCII);
|
||||||
|
static bool advancedMode();
|
||||||
|
static void setAdvancedMode(bool advancedMode);
|
||||||
|
static QString passwordExcludedChars();
|
||||||
|
static void setPasswordExcludedChars(QString chars);
|
||||||
static int passPhraseWordCount();
|
static int passPhraseWordCount();
|
||||||
static void setPassPhraseWordCount(int wordCount);
|
static void setPassPhraseWordCount(int wordCount);
|
||||||
static QString passPhraseWordSeparator();
|
static QString passPhraseWordSeparator();
|
||||||
|
@ -44,19 +44,41 @@ int Generate::execute(const QStringList& arguments)
|
|||||||
parser.setApplicationDescription(this->description);
|
parser.setApplicationDescription(this->description);
|
||||||
QCommandLineOption len(QStringList() << "L"
|
QCommandLineOption len(QStringList() << "L"
|
||||||
<< "length",
|
<< "length",
|
||||||
QObject::tr("Length of the generated password."),
|
QObject::tr("Length of the generated password"),
|
||||||
QObject::tr("length"));
|
QObject::tr("length"));
|
||||||
parser.addOption(len);
|
parser.addOption(len);
|
||||||
QCommandLineOption lower(QStringList() << "l", QObject::tr("Use lowercase characters in the generated password."));
|
QCommandLineOption lower(QStringList() << "l"
|
||||||
|
<< "lower",
|
||||||
|
QObject::tr("Use lowercase characters"));
|
||||||
parser.addOption(lower);
|
parser.addOption(lower);
|
||||||
QCommandLineOption upper(QStringList() << "u", QObject::tr("Use uppercase characters in the generated password."));
|
QCommandLineOption upper(QStringList() << "u"
|
||||||
|
<< "upper",
|
||||||
|
QObject::tr("Use uppercase characters"));
|
||||||
parser.addOption(upper);
|
parser.addOption(upper);
|
||||||
QCommandLineOption numeric(QStringList() << "n", QObject::tr("Use numbers in the generated password."));
|
QCommandLineOption numeric(QStringList() << "n"
|
||||||
|
<< "numeric",
|
||||||
|
QObject::tr("Use numbers."));
|
||||||
parser.addOption(numeric);
|
parser.addOption(numeric);
|
||||||
QCommandLineOption special(QStringList() << "s", QObject::tr("Use special characters in the generated password."));
|
QCommandLineOption special(QStringList() << "s"
|
||||||
|
<< "special",
|
||||||
|
QObject::tr("Use special characters"));
|
||||||
parser.addOption(special);
|
parser.addOption(special);
|
||||||
QCommandLineOption extended(QStringList() << "e", QObject::tr("Use extended ASCII in the generated password."));
|
QCommandLineOption extended(QStringList() << "e"
|
||||||
|
<< "extended",
|
||||||
|
QObject::tr("Use extended ASCII"));
|
||||||
parser.addOption(extended);
|
parser.addOption(extended);
|
||||||
|
QCommandLineOption exclude(QStringList() << "x"
|
||||||
|
<< "exclude",
|
||||||
|
QObject::tr("Exclude character set"),
|
||||||
|
QObject::tr("chars"));
|
||||||
|
parser.addOption(exclude);
|
||||||
|
QCommandLineOption exclude_similar(QStringList() << "exclude-similar",
|
||||||
|
QObject::tr("Exclude similar looking characters"));
|
||||||
|
parser.addOption(exclude_similar);
|
||||||
|
QCommandLineOption every_group(QStringList() << "every-group",
|
||||||
|
QObject::tr("Include characters from every selected group"));
|
||||||
|
parser.addOption(every_group);
|
||||||
|
|
||||||
parser.process(arguments);
|
parser.process(arguments);
|
||||||
|
|
||||||
const QStringList args = parser.positionalArguments();
|
const QStringList args = parser.positionalArguments();
|
||||||
@ -92,8 +114,18 @@ int Generate::execute(const QStringList& arguments)
|
|||||||
classes |= PasswordGenerator::EASCII;
|
classes |= PasswordGenerator::EASCII;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PasswordGenerator::GeneratorFlags flags = 0x0;
|
||||||
|
|
||||||
|
if (parser.isSet(exclude_similar)) {
|
||||||
|
flags |= PasswordGenerator::ExcludeLookAlike;
|
||||||
|
}
|
||||||
|
if (parser.isSet(every_group)) {
|
||||||
|
flags |= PasswordGenerator::CharFromEveryGroup;
|
||||||
|
}
|
||||||
|
|
||||||
passwordGenerator.setCharClasses(classes);
|
passwordGenerator.setCharClasses(classes);
|
||||||
passwordGenerator.setFlags(PasswordGenerator::DefaultFlags);
|
passwordGenerator.setFlags(flags);
|
||||||
|
passwordGenerator.setExcludedChars(parser.value(exclude));
|
||||||
|
|
||||||
if (!passwordGenerator.isValid()) {
|
if (!passwordGenerator.isValid()) {
|
||||||
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli generate");
|
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli generate");
|
||||||
|
@ -21,10 +21,13 @@
|
|||||||
#include "crypto/Random.h"
|
#include "crypto/Random.h"
|
||||||
#include <zxcvbn.h>
|
#include <zxcvbn.h>
|
||||||
|
|
||||||
|
const char* PasswordGenerator::DefaultExcludedChars = "";
|
||||||
|
|
||||||
PasswordGenerator::PasswordGenerator()
|
PasswordGenerator::PasswordGenerator()
|
||||||
: m_length(0)
|
: m_length(0)
|
||||||
, m_classes(0)
|
, m_classes(0)
|
||||||
, m_flags(0)
|
, m_flags(0)
|
||||||
|
, m_excluded(PasswordGenerator::DefaultExcludedChars)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +59,11 @@ void PasswordGenerator::setFlags(const GeneratorFlags& flags)
|
|||||||
m_flags = flags;
|
m_flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PasswordGenerator::setExcludedChars(const QString& chars)
|
||||||
|
{
|
||||||
|
m_excluded = chars;
|
||||||
|
}
|
||||||
|
|
||||||
QString PasswordGenerator::generatePassword() const
|
QString PasswordGenerator::generatePassword() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(isValid());
|
Q_ASSERT(isValid());
|
||||||
@ -130,6 +138,10 @@ bool PasswordGenerator::isValid() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (passwordGroups().size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +152,8 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups() const
|
|||||||
if (m_classes & LowerLetters) {
|
if (m_classes & LowerLetters) {
|
||||||
PasswordGroup group;
|
PasswordGroup group;
|
||||||
|
|
||||||
for (int i = 97; i < (97 + 26); i++) {
|
for (int i = 97; i <= (97 + 25); i++) {
|
||||||
|
|
||||||
if ((m_flags & ExcludeLookAlike) && (i == 108)) { // "l"
|
if ((m_flags & ExcludeLookAlike) && (i == 108)) { // "l"
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -153,7 +166,8 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups() const
|
|||||||
if (m_classes & UpperLetters) {
|
if (m_classes & UpperLetters) {
|
||||||
PasswordGroup group;
|
PasswordGroup group;
|
||||||
|
|
||||||
for (int i = 65; i < (65 + 26); i++) {
|
for (int i = 65; i <= (65 + 25); i++) {
|
||||||
|
|
||||||
if ((m_flags & ExcludeLookAlike) && (i == 73 || i == 79)) { // "I" and "O"
|
if ((m_flags & ExcludeLookAlike) && (i == 73 || i == 79)) { // "I" and "O"
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -176,28 +190,79 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups() const
|
|||||||
|
|
||||||
passwordGroups.append(group);
|
passwordGroups.append(group);
|
||||||
}
|
}
|
||||||
if (m_classes & SpecialCharacters) {
|
if (m_classes & Braces) {
|
||||||
PasswordGroup group;
|
PasswordGroup group;
|
||||||
|
|
||||||
for (int i = 33; i <= 47; i++) {
|
// ()[]{}
|
||||||
group.append(i);
|
group.append(40);
|
||||||
|
group.append(41);
|
||||||
|
group.append(91);
|
||||||
|
group.append(93);
|
||||||
|
group.append(123);
|
||||||
|
group.append(125);
|
||||||
|
|
||||||
|
passwordGroups.append(group);
|
||||||
|
}
|
||||||
|
if (m_classes & Punctuation) {
|
||||||
|
PasswordGroup group;
|
||||||
|
|
||||||
|
// .,:;
|
||||||
|
group.append(44);
|
||||||
|
group.append(46);
|
||||||
|
group.append(58);
|
||||||
|
group.append(59);
|
||||||
|
|
||||||
|
passwordGroups.append(group);
|
||||||
|
}
|
||||||
|
if (m_classes & Quotes) {
|
||||||
|
PasswordGroup group;
|
||||||
|
|
||||||
|
// "'
|
||||||
|
group.append(34);
|
||||||
|
group.append(39);
|
||||||
|
|
||||||
|
passwordGroups.append(group);
|
||||||
|
}
|
||||||
|
if (m_classes & Dashes) {
|
||||||
|
PasswordGroup group;
|
||||||
|
|
||||||
|
// -/\_|
|
||||||
|
group.append(45);
|
||||||
|
group.append(47);
|
||||||
|
group.append(92);
|
||||||
|
group.append(95);
|
||||||
|
if (!(m_flags & ExcludeLookAlike)) {
|
||||||
|
group.append(124); // "|"
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 58; i <= 64; i++) {
|
passwordGroups.append(group);
|
||||||
group.append(i);
|
}
|
||||||
}
|
if (m_classes & Math) {
|
||||||
|
PasswordGroup group;
|
||||||
for (int i = 91; i <= 96; i++) {
|
|
||||||
group.append(i);
|
// !*+-<=>?
|
||||||
}
|
group.append(33);
|
||||||
|
group.append(42);
|
||||||
for (int i = 123; i <= 126; i++) {
|
group.append(43);
|
||||||
if ((m_flags & ExcludeLookAlike) && (i == 124)) { // "|"
|
group.append(60);
|
||||||
continue;
|
group.append(61);
|
||||||
}
|
group.append(62);
|
||||||
|
group.append(63);
|
||||||
|
|
||||||
|
passwordGroups.append(group);
|
||||||
|
}
|
||||||
|
if (m_classes & Logograms) {
|
||||||
|
PasswordGroup group;
|
||||||
|
|
||||||
|
// #$%&
|
||||||
|
for (int i = 35; i <= 38; i++) {
|
||||||
group.append(i);
|
group.append(i);
|
||||||
}
|
}
|
||||||
|
// @^`~
|
||||||
|
group.append(64);
|
||||||
|
group.append(94);
|
||||||
|
group.append(96);
|
||||||
|
group.append(126);
|
||||||
|
|
||||||
passwordGroups.append(group);
|
passwordGroups.append(group);
|
||||||
}
|
}
|
||||||
@ -220,6 +285,27 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups() const
|
|||||||
passwordGroups.append(group);
|
passwordGroups.append(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop over character groups and remove excluded characters from them;
|
||||||
|
// remove empty groups
|
||||||
|
int i = 0;
|
||||||
|
while (i != passwordGroups.size()) {
|
||||||
|
PasswordGroup group = passwordGroups[i];
|
||||||
|
|
||||||
|
for (QChar ch : m_excluded) {
|
||||||
|
int j = group.indexOf(ch);
|
||||||
|
while (j != -1) {
|
||||||
|
group.remove(j);
|
||||||
|
j = group.indexOf(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group.size() > 0) {
|
||||||
|
passwordGroups.replace(i, group);
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
passwordGroups.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return passwordGroups;
|
return passwordGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +322,22 @@ int PasswordGenerator::numCharClasses() const
|
|||||||
if (m_classes & Numbers) {
|
if (m_classes & Numbers) {
|
||||||
numClasses++;
|
numClasses++;
|
||||||
}
|
}
|
||||||
if (m_classes & SpecialCharacters) {
|
if (m_classes & Braces) {
|
||||||
|
numClasses++;
|
||||||
|
}
|
||||||
|
if (m_classes & Punctuation) {
|
||||||
|
numClasses++;
|
||||||
|
}
|
||||||
|
if (m_classes & Quotes) {
|
||||||
|
numClasses++;
|
||||||
|
}
|
||||||
|
if (m_classes & Dashes) {
|
||||||
|
numClasses++;
|
||||||
|
}
|
||||||
|
if (m_classes & Math) {
|
||||||
|
numClasses++;
|
||||||
|
}
|
||||||
|
if (m_classes & Logograms) {
|
||||||
numClasses++;
|
numClasses++;
|
||||||
}
|
}
|
||||||
if (m_classes & EASCII) {
|
if (m_classes & EASCII) {
|
||||||
|
@ -30,19 +30,26 @@ class PasswordGenerator
|
|||||||
public:
|
public:
|
||||||
enum CharClass
|
enum CharClass
|
||||||
{
|
{
|
||||||
LowerLetters = 0x1,
|
LowerLetters = (1 << 0),
|
||||||
UpperLetters = 0x2,
|
UpperLetters = (1 << 1),
|
||||||
Numbers = 0x4,
|
Numbers = (1 << 2),
|
||||||
SpecialCharacters = 0x8,
|
Braces = (1 << 3),
|
||||||
EASCII = 0x10,
|
Punctuation = (1 << 4),
|
||||||
|
Quotes = (1 << 5),
|
||||||
|
Dashes = (1 << 6),
|
||||||
|
Math = (1 << 7),
|
||||||
|
Logograms = (1 << 8),
|
||||||
|
SpecialCharacters = Braces | Punctuation | Quotes | Dashes | Math | Logograms,
|
||||||
|
EASCII = (1 << 9),
|
||||||
DefaultCharset = LowerLetters | UpperLetters | Numbers
|
DefaultCharset = LowerLetters | UpperLetters | Numbers
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(CharClasses, CharClass)
|
Q_DECLARE_FLAGS(CharClasses, CharClass)
|
||||||
|
|
||||||
enum GeneratorFlag
|
enum GeneratorFlag
|
||||||
{
|
{
|
||||||
ExcludeLookAlike = 0x1,
|
ExcludeLookAlike = (1 << 0),
|
||||||
CharFromEveryGroup = 0x2,
|
CharFromEveryGroup = (1 << 1),
|
||||||
|
AdvancedMode = (1 << 2),
|
||||||
DefaultFlags = ExcludeLookAlike | CharFromEveryGroup
|
DefaultFlags = ExcludeLookAlike | CharFromEveryGroup
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(GeneratorFlags, GeneratorFlag)
|
Q_DECLARE_FLAGS(GeneratorFlags, GeneratorFlag)
|
||||||
@ -54,6 +61,7 @@ public:
|
|||||||
void setLength(int length);
|
void setLength(int length);
|
||||||
void setCharClasses(const CharClasses& classes);
|
void setCharClasses(const CharClasses& classes);
|
||||||
void setFlags(const GeneratorFlags& flags);
|
void setFlags(const GeneratorFlags& flags);
|
||||||
|
void setExcludedChars(const QString& chars);
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
@ -61,10 +69,18 @@ public:
|
|||||||
int getbits() const;
|
int getbits() const;
|
||||||
|
|
||||||
static const int DefaultLength = 16;
|
static const int DefaultLength = 16;
|
||||||
|
static const char* DefaultExcludedChars;
|
||||||
static constexpr bool DefaultLower = (DefaultCharset & LowerLetters) != 0;
|
static constexpr bool DefaultLower = (DefaultCharset & LowerLetters) != 0;
|
||||||
static constexpr bool DefaultUpper = (DefaultCharset & UpperLetters) != 0;
|
static constexpr bool DefaultUpper = (DefaultCharset & UpperLetters) != 0;
|
||||||
static constexpr bool DefaultNumbers = (DefaultCharset & Numbers) != 0;
|
static constexpr bool DefaultNumbers = (DefaultCharset & Numbers) != 0;
|
||||||
static constexpr bool DefaultSpecial = (DefaultCharset & SpecialCharacters) != 0;
|
static constexpr bool DefaultSpecial = (DefaultCharset & SpecialCharacters) != 0;
|
||||||
|
static constexpr bool DefaultAdvancedMode = (DefaultFlags & AdvancedMode) != 0;
|
||||||
|
static constexpr bool DefaultBraces = (DefaultCharset & Braces) != 0;
|
||||||
|
static constexpr bool DefaultPunctuation = (DefaultCharset & Punctuation) != 0;
|
||||||
|
static constexpr bool DefaultQuotes = (DefaultCharset & Quotes) != 0;
|
||||||
|
static constexpr bool DefaultDashes = (DefaultCharset & Dashes) != 0;
|
||||||
|
static constexpr bool DefaultMath = (DefaultCharset & Math) != 0;
|
||||||
|
static constexpr bool DefaultLogograms = (DefaultCharset & Logograms) != 0;
|
||||||
static constexpr bool DefaultEASCII = (DefaultCharset & EASCII) != 0;
|
static constexpr bool DefaultEASCII = (DefaultCharset & EASCII) != 0;
|
||||||
static constexpr bool DefaultLookAlike = (DefaultFlags & ExcludeLookAlike) != 0;
|
static constexpr bool DefaultLookAlike = (DefaultFlags & ExcludeLookAlike) != 0;
|
||||||
static constexpr bool DefaultFromEveryGroup = (DefaultFlags & CharFromEveryGroup) != 0;
|
static constexpr bool DefaultFromEveryGroup = (DefaultFlags & CharFromEveryGroup) != 0;
|
||||||
@ -76,6 +92,7 @@ private:
|
|||||||
int m_length;
|
int m_length;
|
||||||
CharClasses m_classes;
|
CharClasses m_classes;
|
||||||
GeneratorFlags m_flags;
|
GeneratorFlags m_flags;
|
||||||
|
QString m_excluded;
|
||||||
|
|
||||||
Q_DISABLE_COPY(PasswordGenerator)
|
Q_DISABLE_COPY(PasswordGenerator)
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
@ -56,8 +57,9 @@
|
|||||||
namespace Tools
|
namespace Tools
|
||||||
{
|
{
|
||||||
|
|
||||||
QString humanReadableFileSize(qint64 bytes)
|
QString humanReadableFileSize(qint64 bytes, quint32 precision)
|
||||||
{
|
{
|
||||||
|
constexpr auto kibibyte = 1024;
|
||||||
double size = bytes;
|
double size = bytes;
|
||||||
|
|
||||||
QStringList units = QStringList() << "B"
|
QStringList units = QStringList() << "B"
|
||||||
@ -67,12 +69,12 @@ namespace Tools
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int maxI = units.size() - 1;
|
int maxI = units.size() - 1;
|
||||||
|
|
||||||
while ((size >= 1024) && (i < maxI)) {
|
while ((size >= kibibyte) && (i < maxI)) {
|
||||||
size /= 1024;
|
size /= kibibyte;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString("%1 %2").arg(QLocale().toString(size, 'f', 2), units.at(i));
|
return QString("%1 %2").arg(QLocale().toString(size, 'f', precision), units.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasChild(const QObject* parent, const QObject* child)
|
bool hasChild(const QObject* parent, const QObject* child)
|
||||||
@ -147,8 +149,8 @@ namespace Tools
|
|||||||
|
|
||||||
bool isHex(const QByteArray& ba)
|
bool isHex(const QByteArray& ba)
|
||||||
{
|
{
|
||||||
for (char c : ba) {
|
for (const unsigned char c : ba) {
|
||||||
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
|
if (!std::isxdigit(c)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,8 +160,8 @@ namespace Tools
|
|||||||
|
|
||||||
bool isBase64(const QByteArray& ba)
|
bool isBase64(const QByteArray& ba)
|
||||||
{
|
{
|
||||||
QRegExp regexp(
|
constexpr auto pattern = R"(^(?:[a-z0-9+]{4})*(?:[a-z0-9+]{3}=|[a-z0-9+]{2}==)?$)";
|
||||||
"^(?:[a-z0-9+/]{4})*(?:[a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$", Qt::CaseInsensitive, QRegExp::RegExp2);
|
QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||||
|
|
||||||
QString base64 = QString::fromLatin1(ba.constData(), ba.size());
|
QString base64 = QString::fromLatin1(ba.constData(), ba.size());
|
||||||
|
|
||||||
@ -318,14 +320,15 @@ namespace Tools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set discretionary access control list
|
// Set discretionary access control list
|
||||||
bSuccess = ERROR_SUCCESS == SetSecurityInfo(GetCurrentProcess(), // object handle
|
bSuccess = ERROR_SUCCESS
|
||||||
SE_KERNEL_OBJECT, // type of object
|
== SetSecurityInfo(GetCurrentProcess(), // object handle
|
||||||
DACL_SECURITY_INFORMATION, // change only the objects DACL
|
SE_KERNEL_OBJECT, // type of object
|
||||||
nullptr,
|
DACL_SECURITY_INFORMATION, // change only the objects DACL
|
||||||
nullptr, // do not change owner or group
|
nullptr,
|
||||||
pACL, // DACL specified
|
nullptr, // do not change owner or group
|
||||||
nullptr // do not change SACL
|
pACL, // DACL specified
|
||||||
);
|
nullptr // do not change SACL
|
||||||
|
);
|
||||||
|
|
||||||
Cleanup:
|
Cleanup:
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class QIODevice;
|
|||||||
namespace Tools
|
namespace Tools
|
||||||
{
|
{
|
||||||
|
|
||||||
QString humanReadableFileSize(qint64 bytes);
|
QString humanReadableFileSize(qint64 bytes, quint32 precision = 2);
|
||||||
bool hasChild(const QObject* parent, const QObject* child);
|
bool hasChild(const QObject* parent, const QObject* child);
|
||||||
bool readFromDevice(QIODevice* device, QByteArray& data, int size = 16384);
|
bool readFromDevice(QIODevice* device, QByteArray& data, int size = 16384);
|
||||||
bool readAllFromDevice(QIODevice* device, QByteArray& data);
|
bool readAllFromDevice(QIODevice* device, QByteArray& data);
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
|
@ -125,8 +125,14 @@ void EditWidget::enableApplyButton(bool enabled)
|
|||||||
|
|
||||||
void EditWidget::showMessage(const QString& text, MessageWidget::MessageType type)
|
void EditWidget::showMessage(const QString& text, MessageWidget::MessageType type)
|
||||||
{
|
{
|
||||||
m_ui->messageWidget->setCloseButtonVisible(false);
|
// Show error messages for a longer time to make sure the user can read them
|
||||||
m_ui->messageWidget->showMessage(text, type, 2000);
|
if (type == MessageWidget::Error) {
|
||||||
|
m_ui->messageWidget->setCloseButtonVisible(true);
|
||||||
|
m_ui->messageWidget->showMessage(text, type, 15000);
|
||||||
|
} else {
|
||||||
|
m_ui->messageWidget->setCloseButtonVisible(false);
|
||||||
|
m_ui->messageWidget->showMessage(text, type, 2000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditWidget::hideMessage()
|
void EditWidget::hideMessage()
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "EditWidgetIcons.h"
|
#include "EditWidgetIcons.h"
|
||||||
#include "ui_EditWidgetIcons.h"
|
#include "ui_EditWidgetIcons.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
@ -93,6 +92,7 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
|
|||||||
SIGNAL(widgetUpdated()));
|
SIGNAL(widgetUpdated()));
|
||||||
|
|
||||||
m_ui->faviconButton->setVisible(false);
|
m_ui->faviconButton->setVisible(false);
|
||||||
|
m_ui->addButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditWidgetIcons::~EditWidgetIcons()
|
EditWidgetIcons::~EditWidgetIcons()
|
||||||
@ -269,7 +269,9 @@ void EditWidgetIcons::fetchFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
addCustomIcon(image);
|
if (!addCustomIcon(image)) {
|
||||||
|
emit messageEditEntry(tr("Custom icon already exists"), MessageWidget::Information);
|
||||||
|
}
|
||||||
} else if (!m_urlsToTry.empty()) {
|
} else if (!m_urlsToTry.empty()) {
|
||||||
m_redirects = 0;
|
m_redirects = 0;
|
||||||
startFetchFavicon(m_urlsToTry.takeFirst());
|
startFetchFavicon(m_urlsToTry.takeFirst());
|
||||||
@ -325,35 +327,66 @@ void EditWidgetIcons::addCustomIconFromFile()
|
|||||||
if (m_database) {
|
if (m_database) {
|
||||||
QString filter = QString("%1 (%2);;%3 (*)").arg(tr("Images"), Tools::imageReaderFilter(), tr("All files"));
|
QString filter = QString("%1 (%2);;%3 (*)").arg(tr("Images"), Tools::imageReaderFilter(), tr("All files"));
|
||||||
|
|
||||||
QString filename = QFileDialog::getOpenFileName(this, tr("Select Image"), "", filter);
|
auto filenames = QFileDialog::getOpenFileNames(this, tr("Select Image(s)"), "", filter);
|
||||||
if (!filename.isEmpty()) {
|
if (!filenames.empty()) {
|
||||||
auto icon = QImage(filename);
|
QStringList errornames;
|
||||||
if (!icon.isNull()) {
|
int numexisting = 0;
|
||||||
addCustomIcon(QImage(filename));
|
for (const auto& filename : filenames) {
|
||||||
|
if (!filename.isEmpty()) {
|
||||||
|
auto icon = QImage(filename);
|
||||||
|
if (icon.isNull()) {
|
||||||
|
errornames << filename;
|
||||||
|
} else if (!addCustomIcon(icon)) {
|
||||||
|
// Icon already exists in database
|
||||||
|
++numexisting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int numloaded = filenames.size() - errornames.size() - numexisting;
|
||||||
|
QString msg;
|
||||||
|
|
||||||
|
if (numloaded > 0) {
|
||||||
|
msg = tr("Successfully loaded %1 of %n icon(s)", "", filenames.size()).arg(numloaded);
|
||||||
} else {
|
} else {
|
||||||
emit messageEditEntry(tr("Can't read icon"), MessageWidget::Error);
|
msg = tr("No icons were loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numexisting > 0) {
|
||||||
|
msg += "\n" + tr("%n icon(s) already exist in the database", "", numexisting);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!errornames.empty()) {
|
||||||
|
// Show the first 8 icons that failed to load
|
||||||
|
errornames = errornames.mid(0, 8);
|
||||||
|
emit messageEditEntry(msg + "\n" + tr("The following icon(s) failed:", "", errornames.size()) +
|
||||||
|
"\n" + errornames.join("\n"), MessageWidget::Error);
|
||||||
|
} else if (numloaded > 0) {
|
||||||
|
emit messageEditEntry(msg, MessageWidget::Positive);
|
||||||
|
} else {
|
||||||
|
emit messageEditEntry(msg, MessageWidget::Information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditWidgetIcons::addCustomIcon(const QImage& icon)
|
bool EditWidgetIcons::addCustomIcon(const QImage& icon)
|
||||||
{
|
{
|
||||||
|
bool added = false;
|
||||||
if (m_database) {
|
if (m_database) {
|
||||||
Uuid uuid = m_database->metadata()->findCustomIcon(icon);
|
// Don't add an icon larger than 128x128, but retain original size if smaller
|
||||||
|
auto scaledicon = icon;
|
||||||
|
if (icon.width() > 128 || icon.height() > 128) {
|
||||||
|
scaledicon = icon.scaled(128, 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uuid uuid = m_database->metadata()->findCustomIcon(scaledicon);
|
||||||
if (uuid.isNull()) {
|
if (uuid.isNull()) {
|
||||||
uuid = Uuid::random();
|
uuid = Uuid::random();
|
||||||
// Don't add an icon larger than 128x128, but retain original size if smaller
|
m_database->metadata()->addCustomIcon(uuid, scaledicon);
|
||||||
if (icon.width() > 128 || icon.height() > 128) {
|
|
||||||
m_database->metadata()->addCustomIcon(uuid, icon.scaled(128, 128));
|
|
||||||
} else {
|
|
||||||
m_database->metadata()->addCustomIcon(uuid, icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
||||||
m_database->metadata()->customIconsOrder());
|
m_database->metadata()->customIconsOrder());
|
||||||
} else {
|
added = true;
|
||||||
emit messageEditEntry(tr("Custom icon already exists"), MessageWidget::Information);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the new or existing icon
|
// Select the new or existing icon
|
||||||
@ -363,6 +396,8 @@ void EditWidgetIcons::addCustomIcon(const QImage& icon)
|
|||||||
|
|
||||||
emit widgetUpdated();
|
emit widgetUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditWidgetIcons::removeCustomIcon()
|
void EditWidgetIcons::removeCustomIcon()
|
||||||
@ -459,7 +494,6 @@ void EditWidgetIcons::updateWidgetsDefaultIcons(bool check)
|
|||||||
m_ui->defaultIconsView->setCurrentIndex(index);
|
m_ui->defaultIconsView->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
m_ui->customIconsView->selectionModel()->clearSelection();
|
m_ui->customIconsView->selectionModel()->clearSelection();
|
||||||
m_ui->addButton->setEnabled(false);
|
|
||||||
m_ui->deleteButton->setEnabled(false);
|
m_ui->deleteButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,7 +508,6 @@ void EditWidgetIcons::updateWidgetsCustomIcons(bool check)
|
|||||||
m_ui->customIconsView->setCurrentIndex(index);
|
m_ui->customIconsView->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
m_ui->defaultIconsView->selectionModel()->clearSelection();
|
m_ui->defaultIconsView->selectionModel()->clearSelection();
|
||||||
m_ui->addButton->setEnabled(true);
|
|
||||||
m_ui->deleteButton->setEnabled(true);
|
m_ui->deleteButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ private slots:
|
|||||||
void fetchReadyRead();
|
void fetchReadyRead();
|
||||||
void fetchCanceled();
|
void fetchCanceled();
|
||||||
void addCustomIconFromFile();
|
void addCustomIconFromFile();
|
||||||
void addCustomIcon(const QImage& icon);
|
bool addCustomIcon(const QImage& icon);
|
||||||
void removeCustomIcon();
|
void removeCustomIcon();
|
||||||
void updateWidgetsDefaultIcons(bool checked);
|
void updateWidgetsDefaultIcons(bool checked);
|
||||||
void updateWidgetsCustomIcons(bool checked);
|
void updateWidgetsCustomIcons(bool checked);
|
||||||
|
@ -42,6 +42,10 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
|
|||||||
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updateButtonsEnabled(QString)));
|
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updateButtonsEnabled(QString)));
|
||||||
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updatePasswordStrength(QString)));
|
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updatePasswordStrength(QString)));
|
||||||
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePasswordShown(bool)));
|
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePasswordShown(bool)));
|
||||||
|
connect(m_ui->buttonSimpleMode, SIGNAL(clicked()), SLOT(selectSimpleMode()));
|
||||||
|
connect(m_ui->buttonAdvancedMode, SIGNAL(clicked()), SLOT(selectAdvancedMode()));
|
||||||
|
connect(m_ui->buttonAddHex, SIGNAL(clicked()), SLOT(excludeHexChars()));
|
||||||
|
connect(m_ui->editExcludedChars, SIGNAL(textChanged(QString)), SLOT(updateGenerator()));
|
||||||
connect(m_ui->buttonApply, SIGNAL(clicked()), SLOT(applyPassword()));
|
connect(m_ui->buttonApply, SIGNAL(clicked()), SLOT(applyPassword()));
|
||||||
connect(m_ui->buttonCopy, SIGNAL(clicked()), SLOT(copyPassword()));
|
connect(m_ui->buttonCopy, SIGNAL(clicked()), SLOT(copyPassword()));
|
||||||
connect(m_ui->buttonGenerate, SIGNAL(clicked()), SLOT(regeneratePassword()));
|
connect(m_ui->buttonGenerate, SIGNAL(clicked()), SLOT(regeneratePassword()));
|
||||||
@ -94,11 +98,34 @@ void PasswordGeneratorWidget::loadSettings()
|
|||||||
{
|
{
|
||||||
// Password config
|
// Password config
|
||||||
m_ui->checkBoxLower->setChecked(config()->get("generator/LowerCase", PasswordGenerator::DefaultLower).toBool());
|
m_ui->checkBoxLower->setChecked(config()->get("generator/LowerCase", PasswordGenerator::DefaultLower).toBool());
|
||||||
|
m_ui->checkBoxLowerAdv->setChecked(config()->get("generator/LowerCase", PasswordGenerator::DefaultLower).toBool());
|
||||||
m_ui->checkBoxUpper->setChecked(config()->get("generator/UpperCase", PasswordGenerator::DefaultUpper).toBool());
|
m_ui->checkBoxUpper->setChecked(config()->get("generator/UpperCase", PasswordGenerator::DefaultUpper).toBool());
|
||||||
|
m_ui->checkBoxUpperAdv->setChecked(config()->get("generator/UpperCase", PasswordGenerator::DefaultUpper).toBool());
|
||||||
m_ui->checkBoxNumbers->setChecked(config()->get("generator/Numbers", PasswordGenerator::DefaultNumbers).toBool());
|
m_ui->checkBoxNumbers->setChecked(config()->get("generator/Numbers", PasswordGenerator::DefaultNumbers).toBool());
|
||||||
m_ui->checkBoxSpecialChars->setChecked(
|
m_ui->checkBoxNumbersAdv->setChecked(
|
||||||
config()->get("generator/SpecialChars", PasswordGenerator::DefaultSpecial).toBool());
|
config()->get("generator/Numbers", PasswordGenerator::DefaultNumbers).toBool());
|
||||||
|
m_ui->advancedBar->setVisible(
|
||||||
|
config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool());
|
||||||
|
m_ui->excludedChars->setVisible(
|
||||||
|
config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool());
|
||||||
|
m_ui->checkBoxExcludeAlike->setVisible(
|
||||||
|
config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool());
|
||||||
|
m_ui->checkBoxEnsureEvery->setVisible(
|
||||||
|
config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool());
|
||||||
|
m_ui->editExcludedChars->setText(
|
||||||
|
config()->get("generator/ExcludedChars", PasswordGenerator::DefaultExcludedChars).toString());
|
||||||
|
m_ui->simpleBar->setVisible(
|
||||||
|
!(config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool()));
|
||||||
|
m_ui->checkBoxBraces->setChecked(config()->get("generator/Braces", PasswordGenerator::DefaultBraces).toBool());
|
||||||
|
m_ui->checkBoxQuotes->setChecked(config()->get("generator/Quotes", PasswordGenerator::DefaultQuotes).toBool());
|
||||||
|
m_ui->checkBoxPunctuation->setChecked(
|
||||||
|
config()->get("generator/Punctuation", PasswordGenerator::DefaultPunctuation).toBool());
|
||||||
|
m_ui->checkBoxDashes->setChecked(config()->get("generator/Dashes", PasswordGenerator::DefaultDashes).toBool());
|
||||||
|
m_ui->checkBoxMath->setChecked(config()->get("generator/Math", PasswordGenerator::DefaultMath).toBool());
|
||||||
|
m_ui->checkBoxLogograms->setChecked(
|
||||||
|
config()->get("generator/Logograms", PasswordGenerator::DefaultLogograms).toBool());
|
||||||
m_ui->checkBoxExtASCII->setChecked(config()->get("generator/EASCII", PasswordGenerator::DefaultEASCII).toBool());
|
m_ui->checkBoxExtASCII->setChecked(config()->get("generator/EASCII", PasswordGenerator::DefaultEASCII).toBool());
|
||||||
|
m_ui->checkBoxExtASCIIAdv->setChecked(config()->get("generator/EASCII", PasswordGenerator::DefaultEASCII).toBool());
|
||||||
m_ui->checkBoxExcludeAlike->setChecked(
|
m_ui->checkBoxExcludeAlike->setChecked(
|
||||||
config()->get("generator/ExcludeAlike", PasswordGenerator::DefaultLookAlike).toBool());
|
config()->get("generator/ExcludeAlike", PasswordGenerator::DefaultLookAlike).toBool());
|
||||||
m_ui->checkBoxEnsureEvery->setChecked(
|
m_ui->checkBoxEnsureEvery->setChecked(
|
||||||
@ -120,11 +147,25 @@ void PasswordGeneratorWidget::loadSettings()
|
|||||||
void PasswordGeneratorWidget::saveSettings()
|
void PasswordGeneratorWidget::saveSettings()
|
||||||
{
|
{
|
||||||
// Password config
|
// Password config
|
||||||
config()->set("generator/LowerCase", m_ui->checkBoxLower->isChecked());
|
if (m_ui->simpleBar->isVisible()) {
|
||||||
config()->set("generator/UpperCase", m_ui->checkBoxUpper->isChecked());
|
config()->set("generator/LowerCase", m_ui->checkBoxLower->isChecked());
|
||||||
config()->set("generator/Numbers", m_ui->checkBoxNumbers->isChecked());
|
config()->set("generator/UpperCase", m_ui->checkBoxUpper->isChecked());
|
||||||
|
config()->set("generator/Numbers", m_ui->checkBoxNumbers->isChecked());
|
||||||
|
config()->set("generator/EASCII", m_ui->checkBoxExtASCII->isChecked());
|
||||||
|
} else {
|
||||||
|
config()->set("generator/LowerCase", m_ui->checkBoxLowerAdv->isChecked());
|
||||||
|
config()->set("generator/UpperCase", m_ui->checkBoxUpperAdv->isChecked());
|
||||||
|
config()->set("generator/Numbers", m_ui->checkBoxNumbersAdv->isChecked());
|
||||||
|
config()->set("generator/EASCII", m_ui->checkBoxExtASCIIAdv->isChecked());
|
||||||
|
}
|
||||||
config()->set("generator/SpecialChars", m_ui->checkBoxSpecialChars->isChecked());
|
config()->set("generator/SpecialChars", m_ui->checkBoxSpecialChars->isChecked());
|
||||||
config()->set("generator/EASCII", m_ui->checkBoxExtASCII->isChecked());
|
config()->set("generator/Braces", m_ui->checkBoxBraces->isChecked());
|
||||||
|
config()->set("generator/Punctuation", m_ui->checkBoxPunctuation->isChecked());
|
||||||
|
config()->set("generator/Quotes", m_ui->checkBoxQuotes->isChecked());
|
||||||
|
config()->set("generator/Dashes", m_ui->checkBoxDashes->isChecked());
|
||||||
|
config()->set("generator/Math", m_ui->checkBoxMath->isChecked());
|
||||||
|
config()->set("generator/Logograms", m_ui->checkBoxLogograms->isChecked());
|
||||||
|
config()->set("generator/ExcludedChars", m_ui->editExcludedChars->text());
|
||||||
config()->set("generator/ExcludeAlike", m_ui->checkBoxExcludeAlike->isChecked());
|
config()->set("generator/ExcludeAlike", m_ui->checkBoxExcludeAlike->isChecked());
|
||||||
config()->set("generator/EnsureEvery", m_ui->checkBoxEnsureEvery->isChecked());
|
config()->set("generator/EnsureEvery", m_ui->checkBoxEnsureEvery->isChecked());
|
||||||
config()->set("generator/Length", m_ui->spinBoxLength->value());
|
config()->set("generator/Length", m_ui->spinBoxLength->value());
|
||||||
@ -276,6 +317,48 @@ void PasswordGeneratorWidget::togglePasswordShown(bool showing)
|
|||||||
m_ui->togglePasswordButton->blockSignals(blockSignals);
|
m_ui->togglePasswordButton->blockSignals(blockSignals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PasswordGeneratorWidget::selectSimpleMode()
|
||||||
|
{
|
||||||
|
m_ui->advancedBar->hide();
|
||||||
|
m_ui->excludedChars->hide();
|
||||||
|
m_ui->checkBoxExcludeAlike->hide();
|
||||||
|
m_ui->checkBoxEnsureEvery->hide();
|
||||||
|
m_ui->checkBoxUpper->setChecked(m_ui->checkBoxUpperAdv->isChecked());
|
||||||
|
m_ui->checkBoxLower->setChecked(m_ui->checkBoxLowerAdv->isChecked());
|
||||||
|
m_ui->checkBoxNumbers->setChecked(m_ui->checkBoxNumbersAdv->isChecked());
|
||||||
|
m_ui->checkBoxSpecialChars->setChecked(m_ui->checkBoxBraces->isChecked() | m_ui->checkBoxPunctuation->isChecked()
|
||||||
|
| m_ui->checkBoxQuotes->isChecked()
|
||||||
|
| m_ui->checkBoxMath->isChecked()
|
||||||
|
| m_ui->checkBoxDashes->isChecked()
|
||||||
|
| m_ui->checkBoxLogograms->isChecked());
|
||||||
|
m_ui->checkBoxExtASCII->setChecked(m_ui->checkBoxExtASCIIAdv->isChecked());
|
||||||
|
m_ui->simpleBar->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PasswordGeneratorWidget::selectAdvancedMode()
|
||||||
|
{
|
||||||
|
m_ui->simpleBar->hide();
|
||||||
|
m_ui->checkBoxUpperAdv->setChecked(m_ui->checkBoxUpper->isChecked());
|
||||||
|
m_ui->checkBoxLowerAdv->setChecked(m_ui->checkBoxLower->isChecked());
|
||||||
|
m_ui->checkBoxNumbersAdv->setChecked(m_ui->checkBoxNumbers->isChecked());
|
||||||
|
m_ui->checkBoxBraces->setChecked(m_ui->checkBoxSpecialChars->isChecked());
|
||||||
|
m_ui->checkBoxPunctuation->setChecked(m_ui->checkBoxSpecialChars->isChecked());
|
||||||
|
m_ui->checkBoxQuotes->setChecked(m_ui->checkBoxSpecialChars->isChecked());
|
||||||
|
m_ui->checkBoxMath->setChecked(m_ui->checkBoxSpecialChars->isChecked());
|
||||||
|
m_ui->checkBoxDashes->setChecked(m_ui->checkBoxSpecialChars->isChecked());
|
||||||
|
m_ui->checkBoxLogograms->setChecked(m_ui->checkBoxSpecialChars->isChecked());
|
||||||
|
m_ui->checkBoxExtASCIIAdv->setChecked(m_ui->checkBoxExtASCII->isChecked());
|
||||||
|
m_ui->advancedBar->show();
|
||||||
|
m_ui->excludedChars->show();
|
||||||
|
m_ui->checkBoxExcludeAlike->show();
|
||||||
|
m_ui->checkBoxEnsureEvery->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PasswordGeneratorWidget::excludeHexChars()
|
||||||
|
{
|
||||||
|
m_ui->editExcludedChars->setText("GHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz");
|
||||||
|
}
|
||||||
|
|
||||||
void PasswordGeneratorWidget::colorStrengthIndicator(double entropy)
|
void PasswordGeneratorWidget::colorStrengthIndicator(double entropy)
|
||||||
{
|
{
|
||||||
// Take the existing stylesheet and convert the text and background color to arguments
|
// Take the existing stylesheet and convert the text and background color to arguments
|
||||||
@ -306,24 +389,69 @@ PasswordGenerator::CharClasses PasswordGeneratorWidget::charClasses()
|
|||||||
{
|
{
|
||||||
PasswordGenerator::CharClasses classes;
|
PasswordGenerator::CharClasses classes;
|
||||||
|
|
||||||
if (m_ui->checkBoxLower->isChecked()) {
|
if (m_ui->simpleBar->isVisible()) {
|
||||||
classes |= PasswordGenerator::LowerLetters;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_ui->checkBoxUpper->isChecked()) {
|
if (m_ui->checkBoxLower->isChecked()) {
|
||||||
classes |= PasswordGenerator::UpperLetters;
|
classes |= PasswordGenerator::LowerLetters;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ui->checkBoxNumbers->isChecked()) {
|
if (m_ui->checkBoxUpper->isChecked()) {
|
||||||
classes |= PasswordGenerator::Numbers;
|
classes |= PasswordGenerator::UpperLetters;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ui->checkBoxSpecialChars->isChecked()) {
|
if (m_ui->checkBoxNumbers->isChecked()) {
|
||||||
classes |= PasswordGenerator::SpecialCharacters;
|
classes |= PasswordGenerator::Numbers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ui->checkBoxExtASCII->isChecked()) {
|
if (m_ui->checkBoxSpecialChars->isChecked()) {
|
||||||
classes |= PasswordGenerator::EASCII;
|
classes |= PasswordGenerator::SpecialCharacters;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxExtASCII->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::EASCII;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (m_ui->checkBoxLowerAdv->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::LowerLetters;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxUpperAdv->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::UpperLetters;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxNumbersAdv->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::Numbers;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxBraces->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::Braces;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxPunctuation->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::Punctuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxQuotes->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::Quotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxDashes->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::Dashes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxMath->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::Math;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxLogograms->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::Logograms;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ui->checkBoxExtASCIIAdv->isChecked()) {
|
||||||
|
classes |= PasswordGenerator::EASCII;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return classes;
|
return classes;
|
||||||
@ -361,7 +489,22 @@ void PasswordGeneratorWidget::updateGenerator()
|
|||||||
if (classes.testFlag(PasswordGenerator::Numbers)) {
|
if (classes.testFlag(PasswordGenerator::Numbers)) {
|
||||||
minLength++;
|
minLength++;
|
||||||
}
|
}
|
||||||
if (classes.testFlag(PasswordGenerator::SpecialCharacters)) {
|
if (classes.testFlag(PasswordGenerator::Braces)) {
|
||||||
|
minLength++;
|
||||||
|
}
|
||||||
|
if (classes.testFlag(PasswordGenerator::Punctuation)) {
|
||||||
|
minLength++;
|
||||||
|
}
|
||||||
|
if (classes.testFlag(PasswordGenerator::Quotes)) {
|
||||||
|
minLength++;
|
||||||
|
}
|
||||||
|
if (classes.testFlag(PasswordGenerator::Dashes)) {
|
||||||
|
minLength++;
|
||||||
|
}
|
||||||
|
if (classes.testFlag(PasswordGenerator::Math)) {
|
||||||
|
minLength++;
|
||||||
|
}
|
||||||
|
if (classes.testFlag(PasswordGenerator::Logograms)) {
|
||||||
minLength++;
|
minLength++;
|
||||||
}
|
}
|
||||||
if (classes.testFlag(PasswordGenerator::EASCII)) {
|
if (classes.testFlag(PasswordGenerator::EASCII)) {
|
||||||
@ -382,6 +525,11 @@ void PasswordGeneratorWidget::updateGenerator()
|
|||||||
|
|
||||||
m_passwordGenerator->setLength(m_ui->spinBoxLength->value());
|
m_passwordGenerator->setLength(m_ui->spinBoxLength->value());
|
||||||
m_passwordGenerator->setCharClasses(classes);
|
m_passwordGenerator->setCharClasses(classes);
|
||||||
|
if (m_ui->simpleBar->isVisible()) {
|
||||||
|
m_passwordGenerator->setExcludedChars("");
|
||||||
|
} else {
|
||||||
|
m_passwordGenerator->setExcludedChars(m_ui->editExcludedChars->text());
|
||||||
|
}
|
||||||
m_passwordGenerator->setFlags(flags);
|
m_passwordGenerator->setFlags(flags);
|
||||||
|
|
||||||
if (m_passwordGenerator->isValid()) {
|
if (m_passwordGenerator->isValid()) {
|
||||||
|
@ -65,6 +65,9 @@ private slots:
|
|||||||
void updateButtonsEnabled(const QString& password);
|
void updateButtonsEnabled(const QString& password);
|
||||||
void updatePasswordStrength(const QString& password);
|
void updatePasswordStrength(const QString& password);
|
||||||
void togglePasswordShown(bool hidden);
|
void togglePasswordShown(bool hidden);
|
||||||
|
void selectSimpleMode();
|
||||||
|
void selectAdvancedMode();
|
||||||
|
void excludeHexChars();
|
||||||
|
|
||||||
void passwordSliderMoved();
|
void passwordSliderMoved();
|
||||||
void passwordSpinBoxChanged();
|
void passwordSpinBoxChanged();
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>547</width>
|
<width>571</width>
|
||||||
<height>352</height>
|
<height>394</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0">
|
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetMinimumSize</enum>
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -175,12 +175,6 @@ QProgressBar::chunk {
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="tabPosition">
|
<property name="tabPosition">
|
||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -204,155 +198,598 @@ QProgressBar::chunk {
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="alphabetLayout" stretch="0,0,0,0,1,0">
|
<widget class="QWidget" name="simpleBar" native="true">
|
||||||
<item>
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<widget class="QToolButton" name="checkBoxUpper">
|
<property name="leftMargin">
|
||||||
<property name="minimumSize">
|
<number>0</number>
|
||||||
<size>
|
</property>
|
||||||
<width>0</width>
|
<property name="topMargin">
|
||||||
<height>25</height>
|
<number>0</number>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="rightMargin">
|
||||||
<property name="focusPolicy">
|
<number>0</number>
|
||||||
<enum>Qt::StrongFocus</enum>
|
</property>
|
||||||
</property>
|
<property name="bottomMargin">
|
||||||
<property name="toolTip">
|
<number>0</number>
|
||||||
<string>Upper Case Letters</string>
|
</property>
|
||||||
</property>
|
<item>
|
||||||
<property name="text">
|
<layout class="QHBoxLayout" name="alphabetLayout" stretch="0,0,0,0,0,0,0">
|
||||||
<string notr="true">A-Z</string>
|
<item>
|
||||||
</property>
|
<widget class="QToolButton" name="checkBoxUpper">
|
||||||
<property name="checkable">
|
<property name="minimumSize">
|
||||||
<bool>true</bool>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<attribute name="buttonGroup">
|
<height>25</height>
|
||||||
<string notr="true">optionButtons</string>
|
</size>
|
||||||
</attribute>
|
</property>
|
||||||
</widget>
|
<property name="focusPolicy">
|
||||||
</item>
|
<enum>Qt::StrongFocus</enum>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QToolButton" name="checkBoxLower">
|
<property name="toolTip">
|
||||||
<property name="minimumSize">
|
<string>Upper Case Letters</string>
|
||||||
<size>
|
</property>
|
||||||
<width>0</width>
|
<property name="text">
|
||||||
<height>25</height>
|
<string notr="true">A-Z</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="checkable">
|
||||||
<property name="focusPolicy">
|
<bool>true</bool>
|
||||||
<enum>Qt::StrongFocus</enum>
|
</property>
|
||||||
</property>
|
<attribute name="buttonGroup">
|
||||||
<property name="toolTip">
|
<string notr="true">optionButtons</string>
|
||||||
<string>Lower Case Letters</string>
|
</attribute>
|
||||||
</property>
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string notr="true">a-z</string>
|
<item>
|
||||||
</property>
|
<widget class="QToolButton" name="checkBoxLower">
|
||||||
<property name="checkable">
|
<property name="minimumSize">
|
||||||
<bool>true</bool>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<attribute name="buttonGroup">
|
<height>25</height>
|
||||||
<string notr="true">optionButtons</string>
|
</size>
|
||||||
</attribute>
|
</property>
|
||||||
</widget>
|
<property name="focusPolicy">
|
||||||
</item>
|
<enum>Qt::StrongFocus</enum>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QToolButton" name="checkBoxNumbers">
|
<property name="toolTip">
|
||||||
<property name="minimumSize">
|
<string>Lower Case Letters</string>
|
||||||
<size>
|
</property>
|
||||||
<width>0</width>
|
<property name="text">
|
||||||
<height>25</height>
|
<string notr="true">a-z</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="checkable">
|
||||||
<property name="focusPolicy">
|
<bool>true</bool>
|
||||||
<enum>Qt::StrongFocus</enum>
|
</property>
|
||||||
</property>
|
<attribute name="buttonGroup">
|
||||||
<property name="toolTip">
|
<string notr="true">optionButtons</string>
|
||||||
<string>Numbers</string>
|
</attribute>
|
||||||
</property>
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string notr="true">0-9</string>
|
<item>
|
||||||
</property>
|
<widget class="QToolButton" name="checkBoxNumbers">
|
||||||
<property name="checkable">
|
<property name="minimumSize">
|
||||||
<bool>true</bool>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<attribute name="buttonGroup">
|
<height>25</height>
|
||||||
<string notr="true">optionButtons</string>
|
</size>
|
||||||
</attribute>
|
</property>
|
||||||
</widget>
|
<property name="focusPolicy">
|
||||||
</item>
|
<enum>Qt::StrongFocus</enum>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QToolButton" name="checkBoxSpecialChars">
|
<property name="toolTip">
|
||||||
<property name="minimumSize">
|
<string>Numbers</string>
|
||||||
<size>
|
</property>
|
||||||
<width>0</width>
|
<property name="text">
|
||||||
<height>25</height>
|
<string notr="true">0-9</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="checkable">
|
||||||
<property name="focusPolicy">
|
<bool>true</bool>
|
||||||
<enum>Qt::StrongFocus</enum>
|
</property>
|
||||||
</property>
|
<attribute name="buttonGroup">
|
||||||
<property name="toolTip">
|
<string notr="true">optionButtons</string>
|
||||||
<string>Special Characters</string>
|
</attribute>
|
||||||
</property>
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string notr="true">/*_& ...</string>
|
<item>
|
||||||
</property>
|
<widget class="QToolButton" name="checkBoxSpecialChars">
|
||||||
<property name="checkable">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<property name="minimumSize">
|
||||||
<string notr="true">optionButtons</string>
|
<size>
|
||||||
</attribute>
|
<width>0</width>
|
||||||
</widget>
|
<height>25</height>
|
||||||
</item>
|
</size>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QToolButton" name="checkBoxExtASCII">
|
<property name="focusPolicy">
|
||||||
<property name="minimumSize">
|
<enum>Qt::StrongFocus</enum>
|
||||||
<size>
|
</property>
|
||||||
<width>0</width>
|
<property name="toolTip">
|
||||||
<height>25</height>
|
<string>Special Characters</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="maximumSize">
|
<string notr="true">/*_& ...</string>
|
||||||
<size>
|
</property>
|
||||||
<width>16777215</width>
|
<property name="checkable">
|
||||||
<height>16777215</height>
|
<bool>true</bool>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<attribute name="buttonGroup">
|
||||||
<property name="focusPolicy">
|
<string notr="true">optionButtons</string>
|
||||||
<enum>Qt::StrongFocus</enum>
|
</attribute>
|
||||||
</property>
|
</widget>
|
||||||
<property name="toolTip">
|
</item>
|
||||||
<string>Extended ASCII</string>
|
<item>
|
||||||
</property>
|
<widget class="QToolButton" name="checkBoxExtASCII">
|
||||||
<property name="text">
|
<property name="minimumSize">
|
||||||
<string>Extended ASCII</string>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<property name="checkable">
|
<height>25</height>
|
||||||
<bool>true</bool>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<property name="maximumSize">
|
||||||
<string notr="true">optionButtons</string>
|
<size>
|
||||||
</attribute>
|
<width>16777215</width>
|
||||||
</widget>
|
<height>16777215</height>
|
||||||
</item>
|
</size>
|
||||||
<item>
|
</property>
|
||||||
<spacer name="horizontalSpacer">
|
<property name="focusPolicy">
|
||||||
<property name="orientation">
|
<enum>Qt::StrongFocus</enum>
|
||||||
<enum>Qt::Horizontal</enum>
|
</property>
|
||||||
</property>
|
<property name="toolTip">
|
||||||
<property name="sizeHint" stdset="0">
|
<string>Extended ASCII</string>
|
||||||
<size>
|
</property>
|
||||||
<width>40</width>
|
<property name="text">
|
||||||
<height>20</height>
|
<string>ExtendedASCII</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="checkable">
|
||||||
</spacer>
|
<bool>true</bool>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonAdvancedMode">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Switch to advanced mode</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Advanced</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="advancedBar" native="true">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxUpperAdv">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Upper Case Letters A to F</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>A-Z</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxLowerAdv">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Lower Case Letters A to F</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>a-z</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxNumbersAdv">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Numbers</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>0-9</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxBraces">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Braces</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>{[(</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxPunctuation">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>35</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Punctuation</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>.,:;</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxQuotes">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>35</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Quotes</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>" '</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxMath">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Math</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><*+!?=</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxDashes">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Dashes</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>\_|-/</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxLogograms">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>105</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Logograms</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>#$%&&@^`~</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="checkBoxExtASCIIAdv">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>105</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Extended ASCII</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ExtendedASCII</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
|
<item alignment="Qt::AlignTop">
|
||||||
|
<widget class="QPushButton" name="buttonSimpleMode">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Switch to simple mode</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Simple</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">optionButtons</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="excludedChars" native="true">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="editExcludedChars">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Character set to exclude from generated password</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelExcludedChars">
|
||||||
|
<property name="text">
|
||||||
|
<string>Do not include:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="buttonAddHex">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add non-hex letters to "do not include" list</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hex</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBoxExcludeAlike">
|
<widget class="QCheckBox" name="checkBoxExcludeAlike">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Excluded characters: "0", "1", "l", "I", "O", "|", "﹒"</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Exclude look-alike characters</string>
|
<string>Exclude look-alike characters</string>
|
||||||
</property>
|
</property>
|
||||||
@ -534,6 +971,19 @@ QProgressBar::chunk {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -585,9 +1035,6 @@ QProgressBar::chunk {
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
@ -607,7 +1054,29 @@ QProgressBar::chunk {
|
|||||||
<tabstop>checkBoxLower</tabstop>
|
<tabstop>checkBoxLower</tabstop>
|
||||||
<tabstop>checkBoxNumbers</tabstop>
|
<tabstop>checkBoxNumbers</tabstop>
|
||||||
<tabstop>checkBoxSpecialChars</tabstop>
|
<tabstop>checkBoxSpecialChars</tabstop>
|
||||||
|
<tabstop>checkBoxExtASCII</tabstop>
|
||||||
|
<tabstop>buttonAdvancedMode</tabstop>
|
||||||
|
<tabstop>checkBoxUpperAdv</tabstop>
|
||||||
|
<tabstop>checkBoxNumbersAdv</tabstop>
|
||||||
|
<tabstop>checkBoxPunctuation</tabstop>
|
||||||
|
<tabstop>checkBoxMath</tabstop>
|
||||||
|
<tabstop>checkBoxLogograms</tabstop>
|
||||||
|
<tabstop>checkBoxBraces</tabstop>
|
||||||
|
<tabstop>checkBoxQuotes</tabstop>
|
||||||
|
<tabstop>checkBoxDashes</tabstop>
|
||||||
|
<tabstop>checkBoxExtASCIIAdv</tabstop>
|
||||||
|
<tabstop>editExcludedChars</tabstop>
|
||||||
|
<tabstop>buttonSimpleMode</tabstop>
|
||||||
<tabstop>checkBoxExcludeAlike</tabstop>
|
<tabstop>checkBoxExcludeAlike</tabstop>
|
||||||
|
<tabstop>checkBoxEnsureEvery</tabstop>
|
||||||
|
<tabstop>tabWidget</tabstop>
|
||||||
|
<tabstop>comboBoxWordList</tabstop>
|
||||||
|
<tabstop>sliderWordCount</tabstop>
|
||||||
|
<tabstop>spinBoxWordCount</tabstop>
|
||||||
|
<tabstop>editWordSeparator</tabstop>
|
||||||
|
<tabstop>buttonGenerate</tabstop>
|
||||||
|
<tabstop>buttonCopy</tabstop>
|
||||||
|
<tabstop>buttonApply</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -190,6 +190,9 @@ add_unit_test(NAME testykchallengeresponsekey
|
|||||||
add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp
|
add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp
|
||||||
LIBS ${TEST_LIBRARIES})
|
LIBS ${TEST_LIBRARIES})
|
||||||
|
|
||||||
|
add_unit_test(NAME testtools SOURCES TestTools.cpp
|
||||||
|
LIBS ${TEST_LIBRARIES})
|
||||||
|
|
||||||
if(WITH_GUI_TESTS)
|
if(WITH_GUI_TESTS)
|
||||||
add_subdirectory(gui)
|
add_subdirectory(gui)
|
||||||
endif(WITH_GUI_TESTS)
|
endif(WITH_GUI_TESTS)
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "config-keepassx-tests.h"
|
#include "config-keepassx-tests.h"
|
||||||
|
|
||||||
#include "core/Metadata.h"
|
#include "core/Metadata.h"
|
||||||
#include "core/Tools.h"
|
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
#include "crypto/CryptoHash.h"
|
#include "crypto/CryptoHash.h"
|
||||||
#include "crypto/kdf/AesKdf.h"
|
#include "crypto/kdf/AesKdf.h"
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
#include "core/Metadata.h"
|
#include "core/Metadata.h"
|
||||||
#include "core/Tools.h"
|
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(TestModified)
|
QTEST_GUILESS_MAIN(TestModified)
|
||||||
|
65
tests/TestTools.cpp
Normal file
65
tests/TestTools.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
|
* version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "TestTools.h"
|
||||||
|
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QTest>
|
||||||
|
|
||||||
|
QTEST_GUILESS_MAIN(TestTools)
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
QString createDecimal(QString wholes, QString fractions, QString unit)
|
||||||
|
{
|
||||||
|
return wholes + QLocale().decimalPoint() + fractions + " " + unit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestTools::testHumanReadableFileSize()
|
||||||
|
{
|
||||||
|
constexpr auto kibibyte = 1024u;
|
||||||
|
using namespace Tools;
|
||||||
|
|
||||||
|
QCOMPARE(createDecimal("1", "00", "B"), humanReadableFileSize(1));
|
||||||
|
QCOMPARE(createDecimal("1", "00", "KiB"), humanReadableFileSize(kibibyte));
|
||||||
|
QCOMPARE(createDecimal("1", "00", "MiB"), humanReadableFileSize(kibibyte * kibibyte));
|
||||||
|
QCOMPARE(createDecimal("1", "00", "GiB"), humanReadableFileSize(kibibyte * kibibyte * kibibyte));
|
||||||
|
|
||||||
|
QCOMPARE(QString("100 B"), humanReadableFileSize(100, 0));
|
||||||
|
QCOMPARE(createDecimal("1", "10", "KiB"), humanReadableFileSize(kibibyte + 100));
|
||||||
|
QCOMPARE(createDecimal("1", "001", "KiB"), humanReadableFileSize(kibibyte + 1, 3));
|
||||||
|
QCOMPARE(createDecimal("15", "00", "KiB"), humanReadableFileSize(kibibyte * 15));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestTools::testIsHex()
|
||||||
|
{
|
||||||
|
QVERIFY(Tools::isHex("0123456789abcdefABCDEF"));
|
||||||
|
QVERIFY(not Tools::isHex(QByteArray("0xnothex")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestTools::testIsBase64()
|
||||||
|
{
|
||||||
|
QVERIFY(Tools::isBase64(QByteArray("1234")));
|
||||||
|
QVERIFY(Tools::isBase64(QByteArray("123=")));
|
||||||
|
QVERIFY(Tools::isBase64(QByteArray("12==")));
|
||||||
|
QVERIFY(Tools::isBase64(QByteArray("abcd9876MN==")));
|
||||||
|
QVERIFY(Tools::isBase64(QByteArray("abcd9876DEFGhijkMNO=")));
|
||||||
|
QVERIFY(not Tools::isBase64(QByteArray("abcd123==")));
|
||||||
|
QVERIFY(not Tools::isBase64(QByteArray("abc_")));
|
||||||
|
QVERIFY(not Tools::isBase64(QByteArray("123")));
|
||||||
|
}
|
32
tests/TestTools.h
Normal file
32
tests/TestTools.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
|
* version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KEEPASSX_TESTTOOLS_H
|
||||||
|
#define KEEPASSX_TESTTOOLS_H
|
||||||
|
|
||||||
|
#include "core/Tools.h"
|
||||||
|
|
||||||
|
class TestTools : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void testHumanReadableFileSize();
|
||||||
|
void testIsHex();
|
||||||
|
void testIsBase64();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KEEPASSX_TESTTOOLS_H
|
Loading…
x
Reference in New Issue
Block a user