MindMap Gallery Programming-notes v2
This is a mind map about programming-notes. The main content includes: installation, configuration and shortcut keys of various IDEs, operation and maintenance, virtualization, cloud computing, database technology, Rust language, Python language, Go language, Java language, C# language, C/C language, computer principles, front-end technology, English learning.
Edited at 2024-03-16 00:54:44This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
No relevant template
Programming-Notes
1. learning English
1. British Standard
2. grammar
3. word
4. sentence
5. daily
6. Business
7. internationality
2. Front-end technology
1. HTML/CSS
1. HTML5
2. CSS 3
2. JavaScript basic application
1. Quick start
2. basic grammar
3. Advanced grammar
4. Grammar topics
5. object-oriented
6. Advanced syntax
7. Comprehensive application and extended learning
3. Advanced grammar
1. ECMAScript 6~13
basic grammar
2. TypeScript
Quick start
3. Less
Quick start
4. backend development
1. Node.js server-side development
Quick start
2. Package and release
webpack
Quick start
5. basic framework
1. React 18
Quick start
2. Vue 2/3
Quick start
6. front-end framework
1. Antd Vue
Quick start
2. antd react
Quick start
7. Extended applications and other learning
1. Chrome browser extension
Quick start
2. WebGL
Quick start
3. computer principles
1. electronic circuit
1. Electrical basics
basic concepts
Common laws
2. Electronic component
Circuit simulation software
Resistor
capacitor
Inductor
relay
fuse
Connector
buzzer
power supply
multimeter
3. Analog circuit
4. Circuit practice
2. Composition principle
3. operating system
4. Network principles
5. Assembly language
6. Compilation technology
7. Microcomputer Principles and Interface Technology
4. C/C language
1. C language
1. Quick start
learning website
https://zh.cppreference.com/w/c
Overview
Environment setup
window
ubuntu
first program
Using IDE
2. basic grammar
constant variable
type of data
operator
Program control
function
define function
Call functions
Array
Array overview
What is an array
Precautions
define array
access array
Traverse array
Multidimensional Arrays
Array parameter passing
3. Advanced grammar
Strings and string functions
Introduction to pointers
Memory management
composite type
File operations
4. Memory principle
base
memory model
Advanced pointers
Pointer enhancement
secondary pointer
array pointer
Function pointers and callback functions
5. Advanced syntax
Assert exception
preprocessing macro
Function variable parameters
programming
C standard library
Premium dedicated themes
international characteristics
6. extended learning
Data Structures and Algorithms
Quick start
learning website
https://www.hello-algo.com/chapter_preface/
Concept Note
data structure
linear structure
array
linked list
stack
queue
Hash table
tree structure
Binary tree
Find tree
AVL tree
red black tree
heap
Graphical structure
diagram concept
directed graph
Undirected graph
graphic definition
graph traversal
Graph Algorithms
algorithm
variable exchange
Sort
Overview of sorting algorithms
Bubble Sort
selection sort
insertion sort
Quick sort
merge sort
Heap sort
Bucket sorting
counting sort
Radix sort
Find
sequential search
binary search
divide and conquer
Backtrack
dynamic rules
Greedy
C 11~23 new standards
C11
7. Comprehensive actual combat
English to Chinese
calculator
Snake
backgammon
Minesweeper
Tetris
Md5 data encryption algorithm
2. C language
1. Quick start
learning website
https://zh.cppreference.com/w/cpp
Environment setup
window
ubuntu
Overview
first program
2. basic grammar
Namespaces
::operator
using directive and using statement
Quote
function
Extensions and enhancements to the C language
3. object-oriented
Classes and Objects
Conceptual explanation of classes and objects
what is class
what is object
Three major characteristics of object-oriented
Definition class
Create object
new and delete keywords
members of class
Constructor
deconstructor
ordinary member
static members
access permission
private
protected
public
const and mutable keywords
Inherit
Ordinary inheritance
diamond inheritance
Inherited permissions
private
protected
public
Polymorphic
virtual function
pure virtual function
Friend Yuan
What is Friendship
friend syntax
Symbol overloading
4. Advanced grammar
Template
streams and files
5. Advanced syntax
Exception handling
STL container
6. extended learning
Boost quasi-standard library
Quick start
learning website
Environment setup
basic grammar
object-oriented
Advanced grammar
container
Advanced syntax
Comprehensive application
Design Patterns
Quick start
learning website
https://design-patterns.readthedocs.io/zh-cn/latest/index.html
https://refactoringguru.cn/design-patterns/cpp
UML class diagram
Design Principles
Creation type
Singleton
prototype
builder
simple factory
Ordinary factory
abstract factory
Structural type
adapter
Decorator
bridge
combine
Exterior
enjoy yuan
acting
behavioral type
observer
visitor
intermediary
Iterator
chain of responsibility
memorandum
Strategy
state
Order
template method
C 11~26 new standard
C 11
Quick start
learning website
obsolete syntax
basic grammar
classes and objects
template method
container algorithm
Advanced syntax
thread
Comprehensive application
C 14
Quick start
learning website
obsolete syntax
basic grammar
classes and objects
template method
container algorithm
Advanced syntax
Comprehensive application
C 17
Quick start
learning website
obsolete syntax
basic grammar
classes and objects
template method
container algorithm
Advanced syntax
Comprehensive application
C 20
Quick start
learning website
obsolete syntax
basic grammar
classes and objects
template method
container algorithm
Advanced syntax
Attributes
concept
constraint
module
coroutine
Comprehensive application
C 23
Quick start
learning website
obsolete syntax
basic grammar
classes and objects
template method
container algorithm
Advanced syntax
Comprehensive application
C 26
Quick start
learning website
obsolete syntax
basic grammar
classes and objects
template method
container algorithm
Advanced syntax
Comprehensive application
7. Comprehensive actual combat
Employee management
3. desktop application
1. Qt cross-platform desktop application
Quick start
learning website
Environment setup
ubuntu
Command installation
1. Install the qt5 development environment sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools 2. Install qt creator sudo apt-get install qtcreator 3. Install other dependent libraries (this library can be installed as required) #Install qml Development environment: sudo apt-get install qtdeclarative5-dev #Install QtMultimedia: sudo apt-get install qtmultimedia5-dev #Install Qtserialport: sudo apt-get install libqt5serialport5-dev #Install opengl development environment: sudo apt-get install libgles2-mesa -dev #Install QtMySQL: sudo apt-get install libqt5sql5-mysql 4. Restart the system sudo reboot
Source code installation
Download and install
window
Download and install
Source code installation
signals and slots
Control programming
event distribution
Advanced programming
database
Comprehensive actual combat
2. Win32
Quick start
learning website
https://github.com/luguanxing/Win32-Programming
Environment setup
Message mechanism
Control programming
Resource call
primitive image
Advanced programming
Comprehensive actual combat
3. MFC
Quick start
learning website
Environment setup
Message mechanism
Control programming
Resource call
primitive image
Advanced programming
Comprehensive actual combat
4. operating system
1. Ubuntu
Quick start
learning website
Environment setup
Overview
Nomenclature
basic naming
View help
List directories
switch path
clear screen
Paginated display
View history
File Directory
Directory management
File management
Users and groups
Group management
User Management
authority management
Related documents
System Management
Process management
View progress
Information description
kill process
Memory management
View memory
Information description
Disk management
view disk
Mount disk
Unmount disk
Log management
View log
network management
View network
Website management
Route management
Software Installation
Command installation
Package installation
Source code installation
Build a server
ssh
ftp
nfs
nc
scp
apache
nginx
basic programming
Vim operation
Quick start
learning website
Environment setup
command mode
edit mode
last line mode
Install plugin
Gcc compile
Debugging
static library
Overview
Write library
Compilation library
Reference library
Dynamic library
Overview
1. What is a dynamic library: 2. The difference between a dynamic library and a static library:
Write library
Compilation library
Reference library
Configuration path
1. Configure header file search path export C_INCLUDE_PATH=$C_INCLUDE_PATH: header file path export CPLUS_INCLUDE=$CPLUS_INCLUDE_PATH: header file path 2. Configure shared library file search path export LIBRARY_PATH=$LIBRARY_PATH: library path 3. Configure runtime library search path export LD_LIBRARY_PATH=$LD_LIBRARY_PATH: library path
Makefile
Quick start
learning website
Environment setup
first script
rule
Rule composition
step by step rule
variable
function
control statement
Advanced syntax
Comprehensive actual combat
system call
File I/O
process
Signal
process communication
thread
Thread communication
Terminal, process group, session, extended process
Telecommunication
Overview
TCP
UDP
local socket
concurrent
I/O multiplexing
HTTP server case
extended learning
linux kernel
Drive development
advanced network
DPDK development
Comprehensive practical combat and extended learning
Shell scripting
Quick start
learning website
basic grammar
variable
control statement
function
Advanced operations
grep
sed
awk
Comprehensive case
mysql operation and maintenance
Service management
CMake project management
Quick start
learning website
https://cmake-doc.readthedocs.io/zh-cn/latest/
Environment setup
ubuntu
centos
mac os
window
Build project
Build executable program
Build static library
Build dynamic library
basic grammar
Print message
Print message
message(1) message("hello cmake") message("arg1" "arg2" "arg3" arg4)
add notes
message(arg1 #[[ arg2 ]] arg3)
Log level
# The log level of message, the lower the maximum level of the sequence number # 1. FATAL_ERROR will terminate the cmake operation and generate printed to stderr # 2. SEND_ERROR cmake will continue to run, and the generated skip printed to stderr # 3. WARNING output warning information printed to stderr # 4. (none) or NOTICE default level printed to stderr # 5. Information that users of the STATUS project may be interested in printed to stdout # 6. VERBOSE detailed information for project users printed to stdout # 7. DEBUG debugging information used by programmers printed to stdout # 8. TRACE is very low-level, implementation details of fine-grained messages printed to stdout # FATAL_ERROR The highest level error message # 1. Will interrupt cmake execution # 2. Will print the file name and line number # message(FATAL_ERROR "test fatal_error") # SEND_ERROR Error that does not interrupt cmake execution # 1. cmake will not be interrupted, but the target program will not be generated. # add_executable add_library # 2. Will print the file name and line number message(SEND_ERROR "test send_error") # WARNING Warning # 1. Will print the file name and line number message(WARNING "test warning") # NOTICE default option # 1. Equivalent to none not set message("test notice 1") message(NOTICE "test notice 2") # STATUS Messages that users are interested in # 1. The output will be prefixed with -- message(STATUS "test status") # VERBOSE Print detailed messages of interest to the user # 1. Not displayed by default # 2. The output will be prefixed with -- message(VERBOSE "test verbose") #DEBUG debugging messages for programmers # 1. Not displayed by default # 2. The output will be prefixed with -- message(DEBUG "test debug") # TRACE debug messages for programmers # 1. Not displayed by default # 2. The output will be prefixed with -- message(TRACE "test trace") # Precautions: # 1. FATAL_ERROR SEND_ERROR WARNING NOTICE STATUS # 1. Output to standard error, 2 # 2. Information is output to standard error by default and will not be output to a file. # 3. Standard error needs to be redirected to standard output before the above messages can be redirected to files. # cmkae -S . -B build > a.log 2>& 1 # 2. VERBOSE, DEBUG, TRACE are not displayed by default. # 1. Output to standard output 1 # 2. Information output to standard output by default will be redirected to a file. # 3. There are two ways to set the log level # set(CMAKE_MESSAGE_LOG_LEVEL TRACE) # cmake -S . -B build --log-level=TRACE
Module lookup log, with nested indented output
# Related logs printed when searching for modules # CHECK_STATUS # Output search module information # CHECK_PASS # Output information about successful search # CHECK_FAIL # Output search failure information # set(CMAKE_MESSAGE_INDENT "--") # Set indentation output log # Note: A set of CHECK_PASS and CHECK_FAIL cannot be output at the same time. set(CMAKE_MESSAGE_LOG_LEVEL VERBOSE) message(CHECK_START "Find xpp") message(CHECK_PASS "Success") message(CHECK_FAIL "Failure") # Nested output module search log message(CHECK_START "Find spdlog module") # Set the log indentation and print the log of the search submodule set(CMAKE_MESSAGE_INDENT "--") message(CHECK_START "Find http module") # message(CHECK_PASS "Success") message(CHECK_FAIL "Failure") set(CMAKE_MESSAGE_INDENT "") # message(CHECK_PASS "Success") message(CHECK_FAIL "Failure")
variable
basic grammar
Set variables
# Set variables set(VAR "hello cmake")
use variables
# Set variables set(VAR "hello cmake") # use variables message(${VAR})
Unload variables
# Set variables set(VAR "hello cmake") # use variables message(${VAR}) # Unload variables unset(VAR) message(${VAR}) # will report an error
Variables and strings
set(VAR1 "hello") # 1. In the string, concatenate the value of the variable set(VAR2 "${VAR1} cmake") message(${VAR2}) # 2. In the string, the variables are output as they are, using escape characters message("\${VAR2}=${VAR2}")
Nested access to variables
set(VAR1 "hello") set(VAR2 "VAR1") # 1. Use the value of one variable as the name of another variable message(${${VAR2}})
Variables let the message output different colors
#[[ 1. Grammar: \033[1,31,41m 1-Highlight 31-Foreground color red 40-Background color black \033[0m adopt the terminal default settings, that is, cancel the color settings 2. Display mode: 0 Terminal default settings 1 Highlight 2 3 4 Use underline 5 flashes 6 7 Highlight display 8 invisible 3. Color: foreground color background color color 30 40 black 31 41 red 32 42 green 33 43 yellow 34 44 blue 35 45 purple 36 46 cyan blue 37 47 white 38 48 39 49 ]] string(ASCII 27 Esc) set(B "${Esc}[") set(E "${Esc}[0m") set(Red "1;31m") set(Yellow "1;33;41m") message("${B}${Red}====This is a red word====${E}") message("${B}${Yellow}====This is a yellow word====${E}")
built-in variables
variables that provide information
PROJECT_NAME
What is saved is the project name in project()
project(demo02_message) message(${PROJECT_NAME}) # Variable to store the project name in project() add_executable(${PROJECT_NAME} main.cpp)
Variables that change behavior
BUILD_SHARED_LIBS
It is a cache variable, global, and cannot be set multiple times
Change the behavior of add_library()
ON Create shared library
OFF creates a static library, default value
# Variables that change the default behavior of add_library, # ON Generate dynamic library # OFF generate static library, default behavior set(BUILD_SHARED_LIBS ON) add_library(${PROJECT_NAME} main.cpp)
Variables that describe the system
MSVC
WIN32
ANDROID
UNIX
Set to True when ten target system or UNIX-like
CMAKE_SYSTERM_NAME
message("MSVC=${MSVC}") message("WIN32=${WIN32}") message("UNIX=${UNIX}") message("ANDROID=${ANDROID}") message("CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}") # window platform #MSVC=1 # WIN32=1 #CMAKE_SYSTEM_NAME=Windows # linux platform #UNIX=1 #CMAKE_SYSTEM_NAME=Linux
Variables that control the build
CMAKE_COLOR_MAKEFILE
Control whether the output of the console Makefile has color
ON has color, default value
OFF no color
set(CMAKE_COLOR_MAKEFILE OFF)
URL of built-in variable
cmake passes variables to c
add_defintions(-DVAR1 -DVAR2 ...)
# Pass macro variables to the c source file, equivalent to gcc -DSPD_LOG #Default value is: 1
# CMakeLists.txt file cmake_minimum_required(VERSION 3.20) project(demo02) add_definitions(-DSPD_LOG) add_executable(${PROJECT_NAME} main.cpp)
// main.cpp file #include <iostream> using namespace std; int main(int argc, char const *argv[]) { #ifdef SPD_LOG cout << "Log output function enabled...!" << endl; #else cout << "The log output function is not enabled...!" << endl; #endif return 0; }
Contains modules
include(file [OPTIONAL] [RESULT_VARIABLE VAR])
Contains common cmake module files
file
Path to xxx.cmake file
OPTIONAL
The file on the path is not found and cmake execution is not terminated.
RESULT_VARIABLE VAR
Store the execution result in the VAR variable
Successful return: the full path of xxx.cmake
Failure returns: NOTFOUND
Case
message("====begin=====================") #include("cmake/compiler_linux_x86_64.cmake") #include("cmake/compiler_linux_x86_642.cmake" OPTIONAL) include("cmake/compiler_linux_x86_64.cmake" OPTIONAL RESULT_VARIABLE Ret) message(${Ret}) message("====after=====================")
subtopic
Automatically find all source code files and header files
aux_source_directory
aux_source_directory(./MySRCS) aux_source_directory(module/http HTTP_SRCS) #Include all .c .cpp files in the specified directory # .h .hpp files will not be included # Will not recurse into subdirectories # If there are multiple directories, they need to be used multiple times
file
cmake_minimum_required(VERSION 3.20) project(demo04_aux_source_directory_and_file) # Use the header file directory in many places and store it in a variable set(INCLUDE_PATHS "./include") include_directories(${INCLUDE_PATHS}) aux_source_directory(./ SRC_CPP) #File system module functions of file # file(GLOB <variable> [LIST_DIRECTORIES true|false] [RELATIVE <path>] [CONFIGURE_DEPENDS] [<globbing-expressions>...]) # 1. Generate matching globbing-expressions and store them in variables # 2. If RELATIVE path is specified, return the relative path on the specified path. # 3. Globbing expressions are similar to regular expressions, but simpler # 4. Added in version 3.3: GLOB lists directories by default - if LIST_DIRECTORIES is set to false, directories are omitted from the results. # 5. Added in version 3.12: If the CONFIGURE_DEPENDS flag is specified, CMake will add logic to the main build system check target to re-run marked GLOB commands at build time. If any output changes, CMake will regenerate the build system. # 6. Note: We do not recommend using GLOB to collect source file lists from the source tree # file(GLOB_RECURSE <variable> [FOLLOW_SYMLINKS] [LIST_DIRECTORIES true|false] [RELATIVE <path>] [CONFIGURE_DEPENDS] [<globbing-expressions>...]) # 1. GLOB_RECURSE mode will traverse all subdirectories of the matching directory and match files # Automatically read the header files in the directory to prevent automatic updates when the header files change. file(GLOB SRC_H "${INCLUDE_PATHS}/*.h*") add_executable(${PROJECT_NAME} ${SRC_CPP} ${SRC_H})
https://cmake-doc.readthedocs.io/zh-cn/latest/command/file.html
Step by step compilation and cleaning of specified targets
subtopic
Step by step compilation and cleaning of specified targets
Generate project files
cmake -S . -B build
cmake -S . -B build -G "NMake Makefiles"
View all catalogs
cmake --build build --target help
Default generated
cmake --build build --target all
preprocessing
cmake --build build --target xxx.i
compile
cmake --build build --target xxx.s
compilation
cmake --build build --target xxx.o
Link
cmake --build build
clean up
cmake --build build --target clean
Set output path to support cross-platform
# CMAKE_LIBRARY_OUTPUT_DIRECTORY dynamic library directory # 1. Only valid for linux .so files # CMAKE_ARCHIVE_OUTPUT_DIRECTORY static library directory # 1. Valid for linux .a files # 2. Valid for windows .lib files # 3. Contains the address of the windows dynamic library.lib file # CMAKE_RUNTIME_OUTPUT_DIRECTORY executable program directory # 1. Executable programs for linux and windows # 2. For windows .dll files # Note: Usually LIBRARY and ARCHIVE set a unified output directory set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
Add subdirectory
Set to output detailed compilation information
# method one: # CMAKE_VERBOSE_MAKEFILE Turn on printing detailed compilation steps: # ON # OFF set(CMAKE_VERBOSE_MAKEFILE ON) # Method 2: cmake --build build -v
Main grammar
control statement
gather
Generate expressions and file operations
Cross-platform C compilation features
Advanced syntax
cross compile
Installation and deployment
unit test
Comprehensive case
CMake project management
Quick start
learning website
Environment setup
basic grammar
Print message
variable
Ordinary variables
Cache variables
Basic syntax and usage of cache variables
set(<variable><value>...CHACHE <type><docstring>[FORCE])
variable variable name
value variable value
CHCHE sets a variable to a cache variable
type
BOOL ON/OFF appears on the cmake-gui interface, and the selection box
FILEPATH appears on the cmake-gui interface, file selection
PATH appears on the cmake-gui interface, directory selection
STRING appears on the cmake-gui interface, fill in the string
INTERNAL appears on the cmake-gui interface and the internal cache is not open to users.
docstring
Description text when the mouse is moved up
FORCE
Forced personalized caching, if the second setting is not set, it will not take effect.
The scope of ordinary variables and global CACHE variables
Ordinary variable scope, itself and submodules
CACHE variable scope is global
Cache variables correspond to cmake-gui and ccmake
windows cmake-gui
linuxccmake
Use option to replace set
CACHE override policy settings
cmake_policy(SET CMP0126 OLD|NEW)
OLD deletes ordinary variables with the same name
NEW does not delete ordinary variables, but cache variables need to be accessed using $CACHE{var_name}
Command line -D cache variables
cmake -S . -B build -D CACHE_VAR1=bbbb
cmake built-in cache variables
attribute variable
Property syntax
set_property(<GLOBAL | DIRECTORY [<dir>] | TARGET [<target1> ...] | SOURCE [<src1> ...] [DIRECTORY <dirs> ...] [TARGET_DIRECTORY <targets> ...] | INSTALL [<file1> ...] | TEST [<test1> ...] [DIRECTORY <dir>] | CACHE [<entry1> ...] > [APPEND] [APPEND_STRING] PROPERTY <name> [<value1> ...])
get_property(<variable> <GLOBAL | DIRECTORY [<dir>] | TARGET <target> | SOURCE <source> [DIRECTORY <dir> | TARGET_DIRECTORY <target>] | INSTALL <file> | TEST <test> [DIRECTORY <dir>] | CACHE <entry> | VARIABLE > PROPERTY <name> [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])
define_property(<GLOBAL | DIRECTORY | TARGET | SOURCE | TEST | VARIABLE | CACHED_VARIABLE> PROPERTY <name> [INHERITED] [BRIEF_DOCS <brief-doc> [docs...]] [FULL_DOCS <full-doc> [docs...]] [INITIALIZE_FROM_VARIABLE <variable>])
Attribute classification
global properties
grammar
Example
directory properties
grammar
Example
file properties
grammar
Example
target attribute
grammar
Example
Print properties
Preset properties
string
gather
function
control statement
if statement
Judgment constant
# ============================================ # 1. Judgment constants # 1. Truth constant: # 1, ON, TRUE, YES, Y, non-zero value (including floating point numbers) # ============================================ if(1) message("1 is true") # true endif() if(ON) message("ON is true") # true endif() if(TRUE) message("TRUE is true") # true endif() if(Y) message("Y is true") # true endif() if(1.1) message("1.1 is true") # true endif() # ============================================ # 2. Judge as false # 0, OFF, FALSE, NO, N, IGNORE, NOTFOUND, empty string # , or the result of -NOTFOUND is false #ignore means ignoring # notfound means not found # ============================================ if(0) message("0 is true") else() message("0 is false") # false endif() if(IGNORE) message("IGNORE is true") else() message("IGNORE is false") # false endif() if(NOTFOUND) message("NOTFOUND is true") else() message("NOTFOUND is false") # false endif() if(xxx-NOTFOUND) message("xxx-NOTFOUND is true") else() message("xxx-NOTFOUND is false") # false endif()
Judgment variable
# ============================================ # 2. Judgment variables # 1. A variable whose value is a true constant is true, and an undefined or other string is false. # 2. Environment variables are always false # 3. Macro parameters are not variables # ============================================ set(VER1 "1") if(${VER1}) # If the value is true, then it is true message("\"1\" is true") # true else() message("\"1\" is false") endif() set(VAR2 "0") if(${VER2}) # If the value is false, then it is false message("\"0\" is true") else() message("\"0\" is false") # false endif() if(${xxxx}) # The value of undefined variables is false message("xxxx undefined is true") else() message("xxxx undefined is false") # false endif() if(VAR0) #The undefined variable name is false message("VAR0 undefined is true") else() message("VAR0 undefined is false") # false endif() set(VAR3 "xxxx") if(VAR3) #The defined variable name is true message("\"xxxx\" is true") # true else() message("\"xxxx\" is false") endif() if(${PATH}) # All system environment variables are flase message("\"PATH\" is true") else() message("\"PATH\" is false") # false endif()
Determine string
# ============================================ # 2. Determine the string # 1. If the constant is true, the string is true, and the other strings are false. # ============================================ if("aaa") # All system environment variables are flase message("\"PATH\" is true") else() message("\"PATH\" is false") # false endif() if("YES") message("\"YES\" is true") # true endif()
Logical Operators
NOT
AND
OR
One dollar comparison
EXISTS determines whether it exists
COMMAND determines whether it is a command
DEFINED determines whether the variable has been defined
binary comparison
comparison operator
EQUAL
equal
LESS
less than
LESS_EQUAL
less than or equal to
GREATER
more than the
GREATER_EQUAL
greater or equal to
String judgment
STREQUAL
STRLESS
STRLESS_EQUAL
STRGREATER
STRGREATER_EQUAL
version judgment
VERSION_EQUAL
VERSION_LESS
VERSION_LESS_EQUAL
VERSION_GREATER
VERSION_GREATER_EQUAL
Regular match
MATCHES
foreach language
while language
Write xxx.cmake in modules
Cache variables
Set properties
Configuration project
Build project
Build executable program
Build static library
Build dynamic library
Automatically find all source files and header files
Set output path
Debugging and compiling
Set to print detailed compilation steps
Set properties
Compilation features
Installation and deployment
unit test
cross compile
Comprehensive case
CMake project management
Quick start
basic grammar
memory pool
Thread Pool
process pool
2. CentOS
Quick start
learning website
Nomenclature
basic naming
File Directory
Users and groups
System Management
network management
Software Installation
Build a server
3. Mac OS
Quick start
learning website
Nomenclature
basic naming
File Directory
Users and groups
System Management
network management
Software Installation
Build a server
4. Window
Quick start
learning website
Nomenclature
basic naming
File Directory
Users and groups
System Management
network management
Software Installation
Build a server
basic programming
system call
network programming
Advanced development
Comprehensive application and extended learning
5. database
1. Manipulating SQLite
2. Operation MySQL8
3. Operation Oracle
4. Operation Redis7
5. Operation PostgreSQL
6. Project actual combat
1. Code management
Git
SVN
2. Win and Linux cross-platform secure transmission management system
3. Cloud disk storage
4. Android taxi hailing
5. Load balancing remote service calling system
6. Intrusion detection and network attack and defense
7. Million concurrent communication engine architecture and implementation
7. Extended learning and other applications
1. Audio and video technology
SDL2 cross-platform multimedia library
Quick start
Basic operations
Advanced operation
Introduction to animation
Animation advanced
Advanced operations
Comprehensive application
FFmpeg
Quick start
learning website
https://wklchris.github.io/blog/
https://ffmpeg-vip.xianwaizhiyin.net zhangxiaogang qitdut1985
Concept Note
video concept
audio concepts
Environment setup
window
Download and install
Source code installation
ubuntu
Command installation
Source code compilation
Install dependencies
Start compiling
Configuration Environment
centos
Download and install
Source code installation
mac os
Source code compilation
Preinstalled environment
Install dependencies
Start compiling
Command list
ffmpeg
video processing
audio processing
subtitle processing
ffplay
play video
plug-in audio
ffprobe
View information
Basic operations
Print supported codecs
Print log
Operation files
Operation directory
Data Principles
Video data storage principle
Audio data storage principle
SDL Basics
Create form
event loop
Play audio
play video
Draw text
SDL rendering audio and video
Play PCM
Play YUV
Unpacking
Decapsulation
Encapsulation
decode encoding
decoding
soft decoding
Hard decoding
coding
minimal parameter encoding
encoding parameters
Advanced processing
video processing
audio processing
Use filters
Comprehensive application and extended learning
GB28181 protocol
Quick start
Create project
Configuration project
GStreamer
Quick start
learning website
Environment setup
window
ubuntu
FreeSWITCH
Quick start
learning website
Environment setup
window
ubuntu
WebRTC
Quick start
local media
Transmission technology
Connection management
media management
Senior Management
signaling server
data channel
Comprehensive application and extended learning
Mobile WebRTC
Native development
Quick start
learning website
Environment setup
window
ubuntu
https://github.com/crow-misia/libwebrtc-bin
WebAssembly
2. AI
Mathematical basis
Image Processing
Scientific Computing
machine learning
deep learning
3. Embedded Development
Single chip microcomputer
C51 microcontroller
Quick start
learning website
development environment
window
ubuntu
STM32 microcontroller
Quick start
learning website
development environment
window
ubuntu
FPGA microcontroller
Quick start
learning website
Environment setup
Arm Architecture and Bare Metal Development
Quick start
learning website
development environment
window
ubuntu
Overview
ARM Company
ARM products
ARM product line
low end
Middle
high-end
authorized manufacturer
ARM architecture
System transplantation
System kernel and driver development
Project actual combat
edge module
Comprehensive practical combat and extended learning
4. game development
3D Mathematical Fundamentals and Game Development
Coordinate System
2D coordinate system
What is a 2D coordinate system
3D coordinate system
What is a 3D coordinate system
left-hand coordinate system
right-hand coordinate system
vector
what is vector
matrix
what is matrix
Primitive
What is a primitive
grid
what is grid
Getting started with the game
Graphics Pipeline (Graphics Pipeline)
View parameters
coordinate space
Color tinting
Light source
atomization
texture mapping
Double cache
Visibility detection
Integrated Security and Extended Learning
Introduction to C game development
Quick start
game interface
CEGUI
Quick start
rendering engine
DirectX 12 3D Game Development Guide
Quick start
learning website
Environment setup
OpenGL
Quick start
learning website
Environment setup
window
Step 1: Download glfw https://www.glfw.org/download.html Step 2: Download glad
ubuntu
Step 1: Download glfw Step 2: Download glad
mac os
Step 1: Download glfw Step 2: Download glad
Vulkan
Quick start
learning website
Environment setup
Game Engine
Cosos Creator
Quick start
learning website
https://www.cocos.com
Environment setup
window
mac os
Unreal Engine
Quick start
learning website
https://www.unrealengine.com/zh-CN
Environment setup
window
mac os
5. Software reverse engineering
Quick start
learning website
Environment setup
6. Cross-language calls
Java language
C# language
Go language
Lua language
Python language
7. Third-party library learning summary
Data serialization
Mini-XML
tinyxml2
cJson
JsonCpp
nlohmann::json
Data encryption and decryption
OpenSSL
Quick start
learning website
https://blog.csdn.net/liao20081228/article/details/77193729
Verify website
https://tool.oschina.net/encrypt?type=2
Environment setup
Window
//http://slproweb.com/products/Win32OpenSSL.html //https://github.com/PowerShell/Win32-OpenSSH/releases //1. Download: Win64OpenSSL-1_1_1d.exe //2. Configure the path environment variable, // 1. C:\UserSoftware\OpenSSL-Win64\bin // 2. Or copy libcrypto.dll to the same directory as the .c file // 3. Or copy libcrypto.dll to the .exe file under Debug in the .sln file //3. Right-click the project properties // 1. Include directory: C:\UserSoftware\OpenSSL-Win64\include // 2. Library directory: C:\UserSoftware\OpenSSL-Win64\lib // 3. Additional dependencies: libcrypto.lib
Ubuntu
//linux //https://github.com/openssl/openssl //Download: openssl-OpenSSL_1_1_1d.tar.gz //1. Decompress //tar -zxvf ./openssl-OpenSSL_1_1_1d.tar.gz //The decompression method for .tar.gz and .gzip is the same: tar -zxvf //2. View the installation manual //vim ./INSTALL Most third-party library manuals are in vim ./README //3. Detect the compilation environment and install // 1)./config // 2) make // 3) sudo make install // 4) openssl version -a //4. Dynamic library not found error: // 1. Find the library location: locate libcrypto.so.1.1 // Result: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 // 2. Configuration library path method 1: Valid for all users globally // sudo vim /etc/ld.so.conf //Add at the end of the file: /usr/lib/x86_64-linux-gnu/ //sudo ldconfig //Let the configuration take effect immediately // 3. Configuration library path method 2: user level, valid for the current user // vim ~/.bashrc //export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH // . ~/.bashrc ^C or source ~/.bashrc // If you can see the corresponding version information, it means it can be used normally. //5. The test code is the same as window //6. Compile: gcc md5.c -lcrypto
Hash encryption
Concept Note
What is hash algorithm
Algorithm classification
//1. Classification of hash algorithms: // 1. md5: // Hash value: 16byte // 2. sha1: // Hash value: 20byte // 3. sha224: // Hash value: 28byte // 4. sha256: // Hash value: 32byte // 5. sha384: // Hash value: 48byte // 6. sha512: // Hash value: 64byte //2. Remarks: // 1. The hash value length mentioned above is the binary data length. // 2. The hash value is usually represented by a digital string in hexadecimal format. // 3. The actual length of the string seen is twice the original length
Related algorithms
MD5 encryption
API function introduction
# define MD5_LONG unsigned int #define MD5_CBLOCK 64 # define MD5_LBLOCK (MD5_CBLOCK/4) #define MD5_DIGEST_LENGTH 16 //Hash value length typedef struct MD5state_st { MD5_LONG A, B, C, D; MD5_LONG Nl, Nh; MD5_LONG data[MD5_LBLOCK]; unsigned int num; } MD5_CTX; //md5 encryption structure //1.Initialization int MD5_Init(MD5_CTX* c); //Parameter Description: // - c parameter, initialize an MD5_CTX variable //2. Add data and perform md5 operation on the data int MD5_Update(MD5_CTX* c, const void* data, size_t len); //Parameter Description: // -c obtained by MD5_Init initialization // - data data for md5 operation // - length of len data string //3. Method 1 of calculating md5 hash value int MD5_Final(unsigned char* md, MD5_CTX* c); //Parameter Description: // - md outgoing parameters, hash value // -c obtained by MD5_Init initialization //instruction manual: // Data to be encrypted can be added multiple times, and large amounts of data can be processed // "hello world! Hello, world" // MD5_Update(c, "hello world!", strlen("hello world!")); // MD5_Update(c, "You,", strlen(" You,")); // MD5_Update(c, "World", strlen("World")); // unsigned char md[16] = { 0 }; // MD5_Final(md, c); //Added multiple times, only after adjusting the MD5_Final function are all encrypted // for (size_t i = 0; i < 16; i ) // { // sprintf(&outresult[i * 2], " x", md[i]); // } //4. Method 2 of calculating md5 hash value unsigned char* MD5(const unsigned char* d, size_t n, unsigned char* md); //Parameter Description: // - d data for md5f operation // - length of n d string // - md outgoing parameters, hash value //instruction manual: // The encrypted data must be added at once, and only a small amount of data can be processed //5. Internal calling function of MD5 void MD5_Transform(MD5_CTX* c, const unsigned char* b);
test program
#include <string> #include <iostream> #include <openssl/md5.h> #include <openssl/sha.h> #pragma warning(disable:4996) using namespace std; void md5Test(const char* p) { //initialization MD5_CTX ctx; int ret = MD5_Init(&ctx); //adding data MD5_Update(&ctx, p, strlen(p)); //Calculation results unsigned char md[MD5_DIGEST_LENGTH] = { 0 }; MD5_Final(md, &ctx); cout << "MD5:" << md << endl; //Result: binary, output garbled code //Format hash value char res[MD5_DIGEST_LENGTH * 2 1] = { 0 }; for (size_t i = 0; i < MD5_DIGEST_LENGTH; i) { sprintf(&res[i*2], " x", md[i]); //&res[i*2] Address: 0 2 4 6 8 rule //"x" formats md[i] into a hexadecimal integer, // It occupies two digits, and if the conversion is less than two digits, fill it with 0 } cout << "Hexadecimal number of MD5:" << res << endl; } int main(int argc, char* argv[]) { const char* str = "hello world"; md5Test(str); system("pause"); return EXIT_SUCCESS; }
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <openssl/md5.h> #pragma warning(disable:4996) void getMD5(const char* str, char* outresult) { MD5_CTX ctx; //initialization MD5_Init(&ctx); //adding data MD5_Update(&ctx, str, strlen(str)); //Calculation results unsigned char md[16] = { 0 }; MD5_Final(md, &ctx); for (size_t i = 0; i < 16; i ) { sprintf(&outresult[i*2],"%02x", md[i]); } } int main(int argc, char* arrgv[]) { char result[33] = { 0 }; getMD5("hello, md5", result); printf("md5 value: %s ", result); system("pause"); return 0; }
Chinese hash value
// sudo apt install unicode // in unicode // Description of the problem of inconsistency between the local Chinese version and the website: // 1. Local Chinese, because the local encoding may occupy two characters // 2. The Chinese URL is converted according to utf8 encoding, which takes up three characters. // https://tool.oschina.net/encrypt?type=2 // 3. The solution: ensure that the local and website encodings are consistent, and then ensure that the md5 encrypted value with Chinese is the same. #include <string> #include <iostream> #include <openssl/md5.h> #include <openssl/sha.h> #include <codecvt> //Coding conversion header file #pragma warning(disable:4996) using namespace std; // Unicode character set conversion UTF8 std::string UnicodeToUTF8(const std::wstring& wstr) { std::string ret; try { std::wstring_convert< std::codecvt_utf8<wchar_t> > wcv; ret = wcv.to_bytes(wstr); } catch (const std::exception & e) { std::cerr << e.what() << std::endl; } return ret; } // UTF8 converts Unicode character set std::wstring UTF8ToUnicode(const std::string& str) { std::wstring ret; try { std::wstring_convert< std::codecvt_utf8<wchar_t> > wcv; ret = wcv.from_bytes(str); } catch (const std::exception & e) { std::cerr << e.what() << std::endl; } return ret; } void md5Test(const char* p) { //initialization MD5_CTX ctx; int ret = MD5_Init(&ctx); //adding data MD5_Update(&ctx, p, strlen(p)); //Calculation results unsigned char md[MD5_DIGEST_LENGTH] = { 0 }; MD5_Final(md, &ctx); cout << "MD5:" << md << endl; //Result: binary, output garbled code //Format hash value char res[MD5_DIGEST_LENGTH * 2 1] = { 0 }; for (size_t i = 0; i < MD5_DIGEST_LENGTH; i) { sprintf(&res[i*2], " x", md[i]); //&res[i*2] Address: 0 2 4 6 8 rule //"x" formats md[i] into a hexadecimal integer, // It occupies two digits, and if the conversion is less than two digits, fill it with 0 } cout << "Hexadecimal number of MD5:" << res << endl; } int main(int argc, char* argv[]) { std::wstring str = L"Hello world, hello world"; string aa = UnicodeToUTF8(str); md5Test(aa.c_str()); system("pause"); return EXIT_SUCCESS; }
Other hash functions
# define SHA_DIGEST_LENGTH 20 # define SHA224_DIGEST_LENGTH 28 # define SHA256_DIGEST_LENGTH 32 # define SHA384_DIGEST_LENGTH 48 #define SHA512_DIGEST_LENGTH 64 typedef struct SHAstate_st { SHA_LONG h0, h1, h2, h3, h4; SHA_LONG Nl, Nh; SHA_LONG data[SHA_LBLOCK]; unsigned int num; } SHA_CTX; int SHA1_Init(SHA_CTX* c); int SHA1_Update(SHA_CTX* c, const void* data, size_t len); int SHA1_Final(unsigned char* md, SHA_CTX* c); unsigned char* SHA1(const unsigned char* d, size_t n, unsigned char* md); void SHA1_Transform(SHA_CTX* c, const unsigned char* data); typedef struct SHA256state_st { SHA_LONG h[8]; SHA_LONG Nl, Nh; SHA_LONG data[SHA_LBLOCK]; unsigned int num, md_len; } SHA256_CTX; int SHA224_Init(SHA256_CTX* c); int SHA224_Update(SHA256_CTX* c, const void* data, size_t len); int SHA224_Final(unsigned char* md, SHA256_CTX* c); unsigned char* SHA224(const unsigned char* d, size_t n, unsigned char* md); int SHA256_Init(SHA256_CTX* c); int SHA256_Update(SHA256_CTX* c, const void* data, size_t len); int SHA256_Final(unsigned char* md, SHA256_CTX* c); unsigned char* SHA256(const unsigned char* d, size_t n, unsigned char* md); void SHA256_Transform(SHA256_CTX* c, const unsigned char* data); typedef struct SHA512state_st { SHA_LONG64 h[8]; SHA_LONG64 Nl, Nh; union { SHA_LONG64 d[SHA_LBLOCK]; unsigned char p[SHA512_CBLOCK]; }u; unsigned int num, md_len; } SHA512_CTX; int SHA384_Init(SHA512_CTX* c); int SHA384_Update(SHA512_CTX* c, const void* data, size_t len); int SHA384_Final(unsigned char* md, SHA512_CTX* c); unsigned char* SHA384(const unsigned char* d, size_t n, unsigned char* md); int SHA512_Init(SHA512_CTX* c); int SHA512_Update(SHA512_CTX* c, const void* data, size_t len); int SHA512_Final(unsigned char* md, SHA512_CTX* c); unsigned char* SHA512(const unsigned char* d, size_t n, unsigned char* md); void SHA512_Transform(SHA512_CTX* c, const unsigned char* data);
Encapsulates general Hash algorithm class
enum HashType { MD5, SAH1, SAH224, SAH256, SAH384, SAH512}; class Hash { public: Hash(HashType type) { m_type = type; switch (type) { case MD5: //Initialize MD5 MD5_Init(); break; case SAH1: break; } } void AddData(string str) { switch (m_type) { case MD5: //adding data MD5_Update(); break; case SAH1: break; } } string GetResult(); ~Hash(); private: HashType m_type; };
Symmetric encryption
Concept Note
//1. Overview: // 1. It is encrypted in blocks. There are only three block sizes: 128bit, 192bit, and 256bit. // 2. What needs to be encrypted must be an integer block of the encrypted block. If it is insufficient, the data needs to be extended to the number of bits of the encrypted block. // 3. Data conversion, for example: int length = (strlen(str) 1 )==0?strlen(str):((strlen(str)/16 1)*16; // 4. The key used for encryption and decryption of symmetric encryption is the same // 5. Symmetric encryption is highly efficient and can be used to encrypt large amounts of data. // 6. Symmetric encryption is reversible and can decrypt the original data. // 7. It is also very safe. When the key length is 256 bits, brute force cracking will take about 3.2 billion years. #define AES_BLOCK_SIZE 16 //Initialize the encrypted key int AES_set_encrypt_key(const unsigned char* userKey, const int bits, AES_KEY* key); //Parameter Description: // -userKey user-defined key, but the length must be 16, 24, 32 characters // -key key ///Initialize the decryption key int AES_set_decrypt_key(const unsigned char* userKey, const int bits, AES_KEY* key); //Parameter Description: // -userKey must be parameter 1 with AES_set_encrypt_key, the user key that is exactly the same //Use this function for both encryption and decryption void AES_cbc_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, unsigned char* ivec, const int enc); //Parameter Description: // -in the data to encrypt or decrypt // -out encrypted or decrypted data -> outgoing parameters // -lenth is the 16-bit integer length of the encrypted and decrypted data. // -key encryption or decryption key information object pointer // -ivec is the dimension array when encrypting or decrypting, and the value of the array must be exactly the same during encryption and decryption, for example: char ivec[AES_BLOCK_SIZE]; // -enc It is a macro parameter indicating encryption or decryption AES_ENCRYPT AES_DECRYPT
Related algorithms
AES encryption and decryption
#include <openssl/aes.h> //encryption string AES_encrypt(string userKey, string dataStr) { int length = dataStr.size() 1; if (length % 16 > 0) { length = (length / 16 1) * 16; } char *buf = new char[length 1]; AES_KEY key; AES_set_encrypt_key((const unsigned char*)userKey.data(), 128, &key); unsigned char ivec[AES_BLOCK_SIZE] = { 0 }; AES_cbc_encrypt((const unsigned char*)dataStr.data(), (unsigned char*)buf, length, &key, ivec, AES_ENCRYPT); string val = string(buf, length); delete[] buf; return val; } //Decrypt string AES_decrypt(string userKey, string dataStr) { const int length = dataStr.length(); char* buf = new char[length 1]; AES_KEY key; AES_set_decrypt_key((const unsigned char*)userKey.data(), 128, &key); unsigned char ivec[AES_BLOCK_SIZE] = { 0 }; AES_cbc_encrypt((const unsigned char*)dataStr.data(), (unsigned char*)buf, length, &key, ivec, AES_DECRYPT); string val = string(buf, length); delete[] buf; return val; } int main(int argc, char* argv[]) { string a = AES_encrypt("1234567887654321", "Hello, world!"); cout << a << endl; string b = AES_decrypt("1234567887654321", a); cout << b << endl; system("pause"); return EXIT_SUCCESS; }
asymmetric encryption
Concept Note
//1. Explanation of the concept of asymmetric encryption: //Performance description: // 1. The longer the RSA algorithm key length, the better the security, and the longer it takes to encrypt and decrypt. // 2. The key length is doubled, and the time required for public key operations is increased by approximately 4 times. // The time required for private key operation increases by approximately 8 times, and the time required for public and private key generation increases by approximately 16 times. //Usage features: // 1. The secret keys used for encryption and decryption are different. // 2. Public key encryption, private key decryption // 3. Private key encryption, public key decryption //Application scenario: // 1. When exchanging secret keys: // 1) Note: When exchanging symmetric encryption keys, you need to use the public key for encryption and the private key for decryption. // 2) Exchange process: // a. The party holding the public key needs to generate a symmetric encryption key (can be time, random number, etc.), encrypt it with the public key, and send it out. // b. The party with the private key receives the data and uses the private key to decrypt it. What is obtained is the original secret key of symmetric encryption. // c. At this time, both communicating parties can use the secret key to symmetrically encrypt the data. // 2. When signing: // 1) Note: When verifying who the data owner is, or verifying whether the data has been modified, the private key needs to be used for encryption and the public key for decryption. // 2) Verification process: // a. The party with the private key signs the data: // 1> Perform a hash operation on the original data to obtain the hash value // 2> Encrypt the hash value with the private key, and send the ciphertext and original data together. // b. The party with the public key verifies the signature of the data: // 1> Receive the data, split the data, and get the ciphertext and original data // 2> After hashing the original data, we get the hash value 1 // 3> Use the public key to decrypt the ciphertext and obtain the hash value 2 // 4> When comparing hash value 1 and hash value 2, if they are the same, there is no problem, if they are not the same, the data has been modified.
Related algorithms
RSA encryption and decryption
The first step is to generate a RAS key pair
//Step one: Generate RSA key pair: #include <openssl/rsa.h> //Apply for a piece of memory RSA* RSA_new(void); BIGNUM* BN_new(void); BIGNUM* e = BN_new(); //BIGNUM needs to be initialized, specify a relatively large integer, used as a random seed BN_set_bit(e, 1000000); //Generate a key pair and store the key in memory int RSA_generate_key_ex(RSA* rsa, int bits, BIGNUM* e, BN_GENCB* cb); //Parameter Description: // - rsa key structure, obtained through RSA_new(), the generated key pair will eventually be stored in this variable // - bits is the length of the key, the unit is bit, calculated in bytes bits/8=1Byte // - e BIGNUM structure variable, obtained through BN_new() // - cb callback function pointer, usually not used, just specify NULL //Extract the public key in the parameter rsa RSA* RSAPublicKey_dup(RSA* rsa); //Extract the private key in the parameter rsa RSA* RSAPrivateKey_dup(RSA* rsa);
The second step is to save the key to the file
pem format writing
//Step 2: Write the RSA key to the file: //Concept description: // 1. The public key and private corner data written in the file is not the original data, but re-encoded data. // 2. It is a PEM file format. The data is encoded using base64. #include <openssl/pem.h> //Write the public key to the file int PEM_write_RSAPublicKey(FILE* fd, const RSA* r); //Parameter Description: // -fd public key file that can be opened through fopen // -r rsa variable that stores public key information //Write the private key to the file int PEM_write_RSAPublicKey(FILE* fd, const RSA* r, const EVP_CIPHER* enc, unsigned char* kstr, int klen, pem_password_cb* cb, void *u); //Parameter Description: // -fd private key file that can be opened through fopen // -r rsa variable that stores private key information // -enc encrypts the private key data, the encryption algorithm used, if not encrypted, specify NULL // -kstr writes NULL. According to analysis: this is the secret key of the symmetric encryption algorithm // -klen The key length of symmetric encryption, no key is specified as 0 // -cb callback function during encryption, do not use NULL unless otherwise specified // -u parameter of callback function, write NULL if no parameter //Read the public key RSA* PEM_read_RSAPublicKey(FILE * fp, RSA * *x, pem_password_cb * cb, void* u); //Parameter Description: // -fp public or private key file opened using fopen // -r outgoing parameter, public key or private key information is written to this variable // -cb callback function, NULL // -u gives callback function parameters, NULL //Read the private key RSA* PEM_read_RSAPrivateKey(FILE * fp, RSA * *x, pem_password_cb * cb, void* u); RSA_free(RSA * r); BN_free(BIGNUM * a); #include <openssl/rsa.h> #include <openssl/pem.h> #ifdef __cplusplus extern "C" { #endif #include <openssl/applink.c> // Fix error: OPENSSL_Uplink(xxxx): no OPENSSL_Applink #ifdef __cplusplus } #endif // __cplusplus void generateKey1() { RSA* r = RSA_new(); BIGNUM* e = BN_new(); BN_set_word(e, 4567); RSA_generate_key_ex(r, 1024, e, NULL); FILE * fp = fopen("publicKey.pem", "w"); PEM_write_RSAPublicKey(fp, r); fclose(fp); fp = fopen("privateKey.pem", "w"); PEM_write_RSAPrivateKey(fp, r, NULL, NULL, 0, NULL, NULL); fclose(fp); RSA_free(r); BN_free(e); }
bio format writing
//Write file in BIO mode: //Create BIO object BIO* BIO_new_file(const char* filename, const char* mode); //Parameter Description: // -filename The file on the disk to be operated on // -mode permissions to operate files, same as the second parameter of fopen //Write the public key int PEM_write_bio_RSAPublicKey(BIO* bp, const RSA* x); //Write private key int PEM_write_bio_RSAPrivateKey(BIO* bp, RSA* x, EVP_CIPHER* enc, unsigned char* kstr, int klen, pem_password_cb* cb, void* u); //Read the public key RSA* PEM_read_bio_RSAPublicKey(BIO* bp, RSA** x, pem_password_cb* cb, void* u); //Read the private key RSA* PEM_read_bio_RSAPrivateKey(BIO* bp, RSA** x, pem_password_cb* cb, void* u); //Flash all the data to the disk, required after each write BIO_flush(RSA* b); int BIO_free(BIO* a); #include <openssl/rsa.h> #include <openssl/pem.h> #ifdef __cplusplus extern "C" { #endif // __cplusplus #include <openssl/applink.c> #ifdef __cplusplus } #endif // __cplusplus void generateKey2() { RSA* r = RSA_new(); BIGNUM* e = BN_new(); BN_set_word(e, 4567); RSA_generate_key_ex(r, 1024, e, NULL); BIO* pubio = BIO_new_file("publicKey.pem", "w"); PEM_write_bio_RSAPublicKey(pubio, r); BIO_flush(pubio); BIO_free(pubio); BIO* priio = BIO_new_file("privateKey.pem", "w"); PEM_write_bio_RSAPrivateKey(priio, r, NULL, NULL, 0, NULL, NULL); BIO_flush(priio); BIO_free(priio); RSA_free(r); BN_free(e); }
The third step is to encrypt and decrypt the data.
//Step 3: Encrypt data // 1. Encrypted in blocks, the length of the encrypted data cannot be greater than the length of the secret key // Assumption: Secret key length: 1024bit/8 = 128Byte //【Master】Usually this is used for data transmission //Public key encryption int RSA_public_encrypt(int flen, const unsigned char* from, unsigned char* to, RSA* rsa, int padding); //Private key decryption int RSA_private_decrypt(int flen, const unsigned char* from, unsigned char* to, RSA* rsa, int padding); //[Understand] Usually this is not used for data transmission //Private key encryption int RSA_private_encrypt(int flen, const unsigned char* from, unsigned char* to, RSA* rsa, int padding); //Public key decryption int RSA_public_decrypt(int flen, const unsigned char* from, unsigned char* to, RSA* rsa, int padding); //Parameter Description: // -flen The length of the data to be added/decrypted -- cannot be greater than the length of the secret key //The maximum length of data that can be encrypted is: the length of the secret key minus 11; // -from the data to be encrypted/decrypted -- passing in parameters // -to store the encrypted or decrypted data -- outgoing transfer number // -rsa public key/private key // -padding fills the end mark, used when reading to indicate that the end of the key has been read. //General use: RSA_PKCS1_PADDING occupies 11 bytes //return value: // Failure: return -1 // Success: Return >0, the length of the binary data after encryption //Use public key encryption string encryptPublicKey() { //1. Get the public key - read the public key from the file FILE* fp = fopen("publicKey.pem", "r"); RSA* pubKey = RSA_new(); PEM_read_RSAPublicKey(fp, &pubKey, NULL, NULL); //2. Prepare encrypted data int keylen = RSA_size(pubKey); // Calculate the maximum length of encryptable data const char* str = "Nima let programming change the world - good good study, day day up!!!"; //3. Use public key encryption char *buf = new char[1024]; memset(buf, 0, sizeof(buf)); int len = RSA_public_encrypt(strlen(str), (const unsigned char*)str, (unsigned char*)buf, pubKey, RSA_PKCS1_PADDING); //4. Return the encrypted data string val = string(buf, len); delete[] buf; RSA_free(pubKey); return val; } //Decrypt using private key string decryptPrivateKey(string encstr) { //1. Get the private key - read the private key from the file FILE* fp = fopen("privateKey.pem", "r"); RSA* priKey = RSA_new(); PEM_read_RSAPrivateKey(fp, &priKey, NULL, NULL); //2. The data to be decrypted is the encstr passed in. int keylen = RSA_size(priKey); // Calculate the maximum length of encryptable data //3. Decrypt using private key char* buf = new char[1024]; memset(buf, 0, sizeof(buf)); int len = RSA_private_decrypt(encstr.size(), (const unsigned char*)encstr.c_str(), (unsigned char*)buf, priKey, RSA_PKCS1_PADDING); //4. Return the encrypted data string val = string(buf, len); delete[] buf; RSA_free(priKey); return val; } int main(int argc, char* arrgv[]) { string str = encryptPublicKey(); cout << "Encrypted data:" << str << endl; string str2 = decryptPrivateKey(str); cout << "Decrypted data:" << str2 << endl; system("pause"); return 0; }
Step 4: Data signature verification
//data signature int RSA_sign(int type, const unsigned char* m, unsigned int m_length, unsigned char* sigret, unsigned int* siglen, RSA * rsa); //Parameter Description: // -type macro, specifies the hash algorithm used, NID_MD5/NID_SHA1/NID_SH224 // -m The data to be signed, // -m_length Signature data length, parameter 2 length strlen(m) // -sigret outgoing parameters, data after signature // -siglen gets the data length after signature // -rsa private key //return value: // Failure: return -1 // Success: Return >0, the length of the signed data //Verify signature int RSA_verify(int type, const unsigned char* m, unsigned int m_length, const unsigned char* sigbuf, unsigned int siglen, RSA * rsa); //Parameter Description: // -type macro, specifies the hash algorithm used, NID_MD5/NID_SHA1/NID_SH224 // -m The data to be signed, // -m_length signature data length // -sigret passed in parameter, signed data sigret, signature to be verified // -siglen To verify the data length of the signature // -rsa public key //return value: // Failure: return -1 // Success: return=1, verification successful //data signature string data_RSASign(string str) { char buf[1024] = { 0 }; unsigned int buflen = 0; RSA* priKey = RSA_new(); BIO* priio = BIO_new_file("privateKey.pem", "r"); PEM_read_bio_RSAPrivateKey(priio, &priKey, NULL, NULL); int ret = RSA_sign(NID_sha1, (const unsigned char*)str.data(), str.length(), (unsigned char*)buf, &buflen, priKey); RSA_free(priKey); BIO_free(priio); return string(buf, buflen); } //verify the data int data_RSAVerify(string str, string sign) { RSA* pubKey = RSA_new(); BIO* pubio = BIO_new_file("publicKey.pem", "r"); PEM_read_bio_RSAPublicKey(pubio, &pubKey, NULL, NULL); int ret = RSA_verify(NID_sha1, (const unsigned char*)str.data(), str.length(), (const unsigned char*)sign.data(), sign.length(), pubKey); RSA_free(pubKey); BIO_free(pubio); return ret; } int main(int argc, char* argv[]) { const char* msg1 = "Hello, world! hello world!"; const char* msg2 = "Hello, world! hello world!"; string str = data_RSASign(msg1); int ret = data_RSAVerify(msg2, str); if (ret == 1)cout << "Verification successful" << endl; else cout << "Verification failed" << endl; system("pause"); return EXIT_SUCCESS; }
Base64 encryption and decryption
base64 algorithm overview
//2. base64 algorithm: // 1. Convert data into binary // 2. Cut a group of 3 characters of the original data and recombine them into 4 characters. // 3. Add a 0 to each character of the original binary number. If there is less than one group at the end, add 0 to make up one group. // 1111 1111 1111 raw binary // 0111 0111 0111 0111 base64 grouped combination // 4. Conclusion: After converting to base64, the data will be longer than the original data.
bio chain processing
//BIO chain processing: // 1. Multiple BIOs can be connected in series in the form of a linked list. // 2. Add the data processing function of each BIO object on the data chain to perform data processing. BIO* md1 = BIO_new(); //md1 hash calculation BIO* md2 = BIO_new(); //md2 hash calculation BIO* b64 = BIO_new(); //base64 encoding and decoding BIO* f = BIO_new(); //Operate disk files //Organize bio chain BIO_push(md1, md2); BIO_push(md2, b64); BIO_push(b64, f); //The obtained BIO is: md1-> md2-> base64-> f //Add data to the chain: int BIO_write(md1, "hello, world", 11); //The data processing process is: // First perform md1 hash calculation -> md2 hash calculation -> base encoding -> write data to disk //BIO function prototype related to base64: //================================================ ================== #include <openssl/bio.h> //BIO is in this header file #include <openssl/evp.h> //BIO_f_base64 in this header file #include <openssl/buffer.h> //BUF_MEM BIO_METHOD* BIO_f_base64(); BIO_METHOD* BIO_s_mem(); BIO* BIO_new(); BIO* BIO_new_mem_buf(void *buf, int len); int BIO_flush(BIO *b); int BIO_read(BIO *b, void *buf, int len); int BIO_write(BIO*b, const void *buf, int len); BIO* BIO_push(BIO*b, BIO* append); BIO* BIO_pop(BIO *b); long BIO_get_mem_ptr(BIO *b, BUF_MEM **pp); void BIO_free_all(BIO *a); typedef struct buf_mem_st BUF_MEM; struct buf_mem_st { size_t length; char* data; size_t max; unsigned long flags; };
Coding steps
//base64 encoding steps: const char* p = "Hello, world!"; // 1. Prepare a base64 BIO object BIO* b64 = BIO_new(BIO_f_base64()); // 2. Prepare a memory BIO object BIO* mem = BIO_new(BIO_s_mem()); // 3. String base64 and memory BIO objects into a bio chain BIO_push(b64, mem); // 4. Add data to the bio chain, encode it in base64 and then write it to the memory BIO. BIO_write(b64, p, strlen(p)); //Calling BIO_write, the base64 object performs encoding operations by default BIO_flush(b64); //This line must be written, otherwise the data will be empty. // 5. Take out the encoded data in the memory for subsequent operations (write to a file or send out) BUF_MEM* memPtr = NULL; BIO_get_mem_ptr(b64, &memPtr); // Store the data in its own buf char* buf = new char[memPtr->length]; memcpy(buf, memPtr->data, memPtr->length);
Decoding steps
//base64 decoding steps: const char* p1 = "Hello, world"; const char* p2 = "SLHSOKDJLNS5"; // 1. Prepare a base64 BIO object BIO* b64 = BIO_new(BIO_f_base64()); // 2. Prepare the BIO chain of base64 data #if 1 //Method 1: Source data BIO* mem = BIO_new(BIO_s_mem()); b64 = BIO_push(b64, mem); BIO_write(b64, p1, strlen(p1)); #else //Method 2: base64 data BIO* mem = BIO_new_mem_buf(p2, strlen(p2)); b64 = BIO_push(b64, mem); #endif // 0 // 3. Read memory char *buf =new char[len]; int ret = BIO_read(mem, buf, sizeof(buf));
Code
#include <string> #include <iostream> #include <openssl/bio.h> //BIO is in this header file #include <openssl/evp.h> //BIO_f_base64 in this header file #include <openssl/buffer.h> //BUF_MEM in this header file #pragma warning(disable:4996) using namespace std; string base64Encode(string src) { BIO* b64 = BIO_new(BIO_f_base64()); BIO* mem = BIO_new(BIO_s_mem()); b64 = BIO_push(b64, mem); int ret = BIO_write(b64, src.data(), src.length()); BIO_flush(b64); //This line must be written, otherwise the data will be empty. BUF_MEM* memPtr = NULL; BIO_get_mem_ptr(b64, &memPtr); return string(memPtr->data, memPtr->length); } string base64Decode(string base64) { int len = base64.length(); BIO* b64 = BIO_new(BIO_f_base64()); BIO* mem = BIO_new_mem_buf(base64.data(), len); b64 = BIO_push(b64, mem); int buflen = len 1; char* buf = new char[buflen]; int ret = BIO_read(b64, buf, len); string str = string(buf, ret); delete[] buf; return str; } int main(int argc, char* argv[]) { string str = base64Encode("Hello, world! You're a turtle soup cook"); cout << str << endl; cout << base64Decode(str) << endl; system("pause"); return EXIT_SUCCESS; }
Parallel computing library
Network request library
5. C# language
1. Quick start
1. learning website
2. Environment setup
2. basic grammar
3. object-oriented
4. Advanced grammar
5. Advanced syntax
6. database
1. ADO.NET
2. LINQ
3. Entity Framework
4. SqlSugar
7. Comprehensive application and extended learning
1. desktop application
WinForms
WPF
2. website development
ASP.net WebForms
ASP.netMVC
ASP.net MVC Core
3. data sharing
WebService
WCF
ASP.net WebApi
6. Java language
1. Quick start
1. learning website
2. Environment setup
2. basic grammar
3. object-oriented
4. Advanced grammar
5. Advanced syntax
6. database
1. JDBC
2. connection pool
7. Comprehensive application and extended learning
1. desktop application
2. website development
3. Android development
7. Go language
1. Quick start
1. learning website
2. Environment setup
2. Advanced grammar
3. object-oriented
4. basic grammar
5. Advanced syntax
6. database
7. Comprehensive application and extended learning
1. desktop application
2. website development
8. Python language
1. Quick start
1. learning website
2. Environment setup
2. basic grammar
3. object-oriented
4. Advanced grammar
5. Advanced syntax
6. database
1. SQLite
2. MySQL8
7. Comprehensive application and extended learning
1. Reptile
2. website development
3. desktop development
4. AI
learning website
https://ailearning.apachecn.org/
Mathematical basis
Scientific Computing
data mining
machine learning
deep learning
Pytorch
Quick start
learning website
Environment setup
Tensor
Create tensor
Numeral Calculations
type conversion
Concatenate tensors
Index operations
Shape operations
Arithmetic function
Automatic Differentiation Module
Build a linear regression
Model definition method
Saving and loading models
Network basics
convolutional neural
Circulating nerves
Advanced operations
Comprehensive application and extended learning
Tensorflow
PaddlePaddle
Yolo
yolov5
Quick start
learning website
Environment setup
ubuntu
Install miniconda
Download miniconda
Install miniconda
Configure domestic mirroring
Install pytorch
Install yolov5
window
Install miniconda
Install pytorch
Install yolov5
Execution case
basic execution
Specify model
Specify input
Specify threshold
Specify IOU
Embed code
Step 1: In the yolov5 environment of conda, install jupyterlab pip install jupyterlab Step 2: Create files 1. Open the yolov5 source code root directory with vscode 2. In the root directory, create the file hub_detect.ipynb 3. In vscode, Double-click hub_detect.ipynb to open the third step: enter the following content: import torch # model # Parameter one: the path to the directory where the model is located # Parameter two: the name of the model file, the .pt suffix cannot be added # Parameter three: Represents the local yolov5 environment model = torch.hub.load("./", "yolov5s", source="local") # images # The content to be detected, img = "./data/images/zidane.jpg" # infererce # Call the model and perform detection results = model(img) # results # Display the detection results results.show() Step 4: Click to run
data preparation
data collection
1. Ready-made pictures 2. Video or camera frames
Label data
1. Before installing the labeling tool, you must first install the qt basic library sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools 2. Install the labeling tool pip install labelimg
Data adjustment
training data
Use the GUI
Model prediction
yolov8
MxNet
Theano
Transformer
9. Rust language
1. Quick start
1. learning website
https://www.rust-lang.org/zh-CN/
https://course.rs/advance/macro.html
https://kaisery.github.io/trpl-zh-cn/
2. Environment setup
2. basic grammar
3. object-oriented
4. Advanced grammar
5. Advanced syntax
6. database
7. Comprehensive application and extended learning
1. website development
10. Database Technology
1. SQLServer
1. Quick start
1. learning website
2. Environment setup
1. window
2. Basic operations
3. Library operations
4. Table operations
5. Data operations
6. Advanced operations
7. extended learning
2. SQLite
1. Quick start
1. learning website
2. Environment setup
1. ubuntu
2. centos
3. mac os
4. window
2. Basic operations
3. Library operations
4. Table operations
5. Data operations
6. Advanced operations
7. extended learning
3. MySQL8
1. Quick start
1. learning website
2. Environment setup
1. ubuntu
2. centos
3. mac os
4. window
2. Basic operations
3. Library operations
4. Table operations
5. Data operations
6. Advanced operations
7. extended learning
4. Oracle
1. Quick start
1. learning website
2. Environment setup
1. ubuntu
2. centos
3. mac os
4. window
2. Basic operations
3. Library operations
4. Table operations
5. Data operations
6. Advanced operations
7. extended learning
5. Redis7
1. Quick start
1. learning website
2. Environment setup
2. Basic operations
3. Library operations
4. Table operations
5. Data operations
6. Advanced operations
7. extended learning
6. PostgreSQL
1. Quick start
1. learning website
2. Environment setup
1. ubuntu
2. centos
3. mac os
4. window
2. Basic operations
3. Library operations
4. Table operations
5. Data operations
6. Advanced operations
7. extended learning
11. Operation and maintenance, virtualization, cloud computing
1. System basics
2. Service management
3. Operation and maintenance practice
4. Operation and maintenance security
5. container
1. docker
6. Container orchestration
1. k8s
2. k3s
7. Comprehensive practical combat and extended learning
12. Installation, configuration and shortcut keys of various IDEs
1. Visual Studio 2022
2. VsCode
3. Qt
4. IDEA