software diagrams

architeture diagrams

flow chart

  • flowchart
  • workflow
  • cross functional chart
  • data flow

UML

  • activity diagram 活动图
  • sequence 时序图
  • state machine 状态
  • user case 状态图
  • class 类图
  • object 对象图
  • component 组件图
  • flow chart 流程图

db mysql

index

常见模型

  • 哈希表
  • 有序数组
  • 搜索树

哈希表

  • 键值(key-value)
  • 新增、查询都比较快
  • 区间查询慢)
  • 适合场景: 等值查询情况的NoSQL

有序数组

  • 等值查询、区间有很快
  • 二分查询 O(log N)
  • 更新数据麻烦,需要挪动数据
  • 适合场景: 平台存储引擎(不会更新)

搜索树

  • 二叉树,搜索效率最高。索引基本都是多叉树,因为需要存到磁盘
  • 大数据量时,二叉树高度太高,需要多次读盘

InnoDB的索引模型

  • 每一个索引在InnoDB里面对应一颗B+树

类型

  • 主键索引 : 叶子节点存储的是整行数据 (clustered index)
  • 非主键索引 :叶子节点存储的主键的值 (secondary index)

覆盖索引

索引的叶子节点上,已经包含要查询的数据,不需要回表去主索引查询数据。

普通索引 & 唯一索引

唯一索引可能引起多读一次数据


java base

Inheritance [1/4]

subclass superclass The super keyword

IS-A Relationship

Polymorphism [2/4]

Virtual Methods

overridden methods /virtual method invocation

Abstraction [3/4]

Encapsulation [4/4]

  • The fields of a class can be made read-only or write-only.
  • A class can have total control over what is stored in its fields.

Abstract Class Interfaces

PECS

Producer extends and Consumer super

Java SE

  • JVM、 language、library features(API)
  • JSR–>多个features/enhancements(JEPs)

primitive types

  • numberic types
    • integral types
      • byte 8-bit
      • short 16-bit( from -32768 to 32767 (-2 to 2 - 1), inclusive)
      • int 32-bit
      • long 64-bit
      • char 16-bit unsigned integers(from 0 to 65535 inclusive)
    • floating-point types
      • float
      • double positive and negative zeros
  • boolean type
    • true and false
  • returnAddress type pointers to the opcodes of JVM instructions. reference types

variables=变量 arguments=参数 parameters methods=方法 constant pool field method data comment : There are two kinds of comments

4 类型、值、变量(Types, Values, and Variables) 4.1 类型和值的种类(The Kinds of Types and Values) 4.2 私有类型和值(Primitive Types and Values) 4.3 引用类型和值(Reference Types and Values) 4.4 类型变量(Type Variables)

类型变量是一个未限定的标识符,在类、接口、方法和构造函数体中作为类型使用。 T就是 Type Varialle

// <T extends Object>
// <T> 

class Test {
        <T extends C & I> void test(T t) {
            t.mI();           // OK
            t.mCPublic();     // OK
            t.mCProtected();  // OK
            t.mCPackage();    // OK
            t.mCPrivate();    // Compile-time error
} }

4.5 Parameterized Types

4.6 Type Erasure

4.7 Reifiable Types

4.8 Raw Types

4.9 Intersection Types

4.10 Subtyping

Callable Future

Callable call()

lock and monitor – Java Concurrency

How to work with wait(), notify() and notifyAll()

Difference between sleep() and wait()

  • wait() – Call on an object; current thread must synchronize on the lock object.
  • sleep() – Call on a Thread; always currently executing thread.

CAS Algorithm

Thread Safety

ThreadFactory

CountDownLatch

BlockingQueue

forkjoin

The ForkJoinPool is basically a specialized implementation of ExecutorService

  • java.util.Arrays class for its parallelSort() methods
  • Stream.parallel()

java14

  • record
  • switch
  • NPE

jdk 16

  • ZGC: Concurrent Thread-Stack Processing

  • Mercurial to Git? why
  • JEP 380: Unix-Domain Socket Channels

For local, inter-process communication, Unix-domain sockets are both more secure and more efficient than TCP/IP loopback connections.

Specification

  • features
    • It requires two or more weeks of development effort to design and implement,
    • It is a significant change worthy of wide review, or
    • It is in high demand by the Java community.
  • enhancements (除了features就是enhancement)

Specification的结构

  • API features,
  • enhancements,
  • clarifications,
  • bug fixes.

  • Annex 1 is the complete Java SE 14 【API Specification】
  • Annex 2 is an annotated API specification showing the 【exact differences】 relative to Java SE XX(previous)
  • Annex 3 The Java Language Specification and The Java Virtual Machine Specification
  • Annex 4 Java Object Serialization Specification in connection with preview features in Java SE 14.

JLS Java Language Specification

module

一组packages为了重用。 21 standard modules

  • Chapter 2

Specification Grammars

2.1 Context-Free Grammars 2.2 The Lexical Grammar 2.3 The Syntactic Grammar 2.4 Grammar Notation

  • Chapter 3

Lexical Structure

3.1 Unicode 3.2 Lexical Translations 3.3 Unicode Escapes 3.4 Line Terminators 3.5 Input Elements and Tokens 3.6 White Space 3.7 Comments 3.8 Identifiers 3.9 Keywords 3.10 Literals

  • Chapter 4 Types, Values, and Variables

4.1 The Kinds of Types and Values 4.2 Primitive Types and Values

statically typed language(静态类型语言): 变量和表达式在编译时就知道了。 strongly typed language(强类型语言)

primitive types:原始类型 boolean type numeric types: byte, short, int, long, char, float, # floating-point double reference types:引用类型 class types interface types array types type variables null type can always be assigned or cast to any reference type

Floating-Point Types, Formats, and Values

  • Objects An object is a class instance or an array.

Each object is associated with a monitor, which is used by synchronized methods and the synchronized statement to provide control over concurrent access to state by multiple threads

Reifiable types

available at run time.

Raw Types

Variables

A variable is a storage location and has an associated type, sometimes called its compile-time type, that is either a primitive type or a reference type

  • a variable is cheched at compile time. but, arrays, a run-time check ia made.
  • There are eight kinds of variables
    • static or an interface declaration
    • whithout using the keywork static
    • Array components
    • Method parameters
    • Constructor prameters
    • Lambda parameters
    • Exception parameter
    • Local variables
class Point {
    static int numPoints;   // numPoints is a class variable
    int x, y;               // x and y are instance variables
    int[] w = new int[10];  // w[0] is an array component
    int setX(int x) {       // x is a method parameter
        int oldx = this.x;  // oldx is a local variable
        this.x = x;
        return oldx;
    } 
}

the state of a object:

  • final Variables

may only be assigned to once.

Conversions and Contexts

  • poly expression

5.1 Kinds of Conversion

5.1.1 Identity Conversion 5.1.2 Widening Primitive Conversion 5.1.3 Narrowing Primitive Conversion 5.1.4 Widening and Narrowing Primitive Conversion

5.1.7 Boxing Conversion 5.1.8 Unboxing Conversion 5.1.9 Unchecked Conversion 5.1.10 Capture Conversion

5.1.11 String Conversion 5.1.12 Forbidden Conversions 5.1.13 Value Set Conversion

类型转换Determining the Meaning of a Name

  • boxing conversion
  • unboxing conversion

5.2 Assignment Contexts 5.3 Invocation Contexts 5.4 String Contexts 5.5 Casting Contexts 5.6 Numeric Contexts

Names

6.1 Declarations 6.2 Names and Identifiers 6.3 Scope of a Declaration 6.4 Shadowing and Obscuring 6.4.1 Shadowing 6.4.2 Obscuring 6.5 Determining the Meaning of a Name 6.6 Access Control 6.6.1 Determining Accessibility 6.6.2 Details on protected Access 6.7 Fully Qualified Names and Canonical Names

Declarations

  • Package Names and Module Names
  • Type Variable Names (E,K,V,T,X) 泛型类型
  • Method Names verbs or verb phrases 小写开始,驼峰
  • Field Names nouns, noun phrases, or abbreviations for nouns. well-designed classes have very few public or protected fields, except for fields that are constants (static final fields).
  • Constant Names
  • Local Variable and Parameter Names

Names and Identifiers Shadowing

Determining the Meaning of a Name

  • ModuleName
  • PackageName
  • TypeName
  • ExpressionName
  • MethodName
  • PackageOrTypeName
  • AmbiguousName

Access Control

Determining Accessibility public / protected / private

7 Packages and Modules

7.1 Package Members

7.2 Host Support for Modules and Packages

7.3 Compilation Units

7.4 Package Declarations

7.5 Import Declarations

Class

members

  • fields
  • methods
  • nested classes
  • interfaces

  • instance
  • static initializers
  • constructors

8.1 Class Declarations

final Classes

A class can be declared final if its definition is complete and no subclasses are desired or required.

strictfp Classes

be explicitly FP-strict (§15.4)

8.1.3 Inner Classes and Enclosing Instances 8.1.4 Superclasses and Subclasses 8.1.5 Superinterfaces

8.2 Class Members

Constructors, static initializers, and instance initializers are not members and therefore are not inherited.

8.3 Field Declarations

Each declarator in a FieldDeclaration declares one field. The Identifier in a declarator may be used in a name to refer to the field.

8.3.1 Field Modifiers

  • static Fields
  • finalFields
  • transient Fields
  • volatile Fields

8.4 Method Declarations 8.4.1 Formal Parameters 8.4.2 Method Signature 8.4.3 Method Modifiers

  • abstractMethods
  • staticMethods
  • finalMethods
  • nativeMethods
  • strictfpMethods
  • synchronizedMethods

8.4.4 Generic Methods 8.4.5 Method Result 8.4.6 Method Throws 8.4.7 Method Body 8.4.8 Inheritance, Overriding, and Hiding 8.4.9 Overloading

8.5 Member Tye Declarations 8.6 Instance Initializers 8.7 Static Initializers 8.8 Constructor Declarations 8.9 Enum Types

Interfaces

9.1 Interface Declarations 9.1.3 zsuperinterfaces and subinterfaces 9.2 Interface Members 9.3 Field (Constant) Declarations 9.4 Method Declarations 9.4.1 Inheritance and Overriding 9.4.2 Overloading

9.5 Member Type Declarations 9.6 Annotation Types

9.6.4 Predefined Annotation Types 9.7 Annotations 9.8 Functional Interfaces 9.9 Function Types

Arrays

  • 10.1 Array Types
  • 10.2 Array Variables
  • 10.3 Array Creation
  • 10.4 Array Access
  • 10.5 Array Store Exception
  • 10.6 Array Initializers
  • 10.7 Array Members
  • 10.8 Class Objects for Arrays
  • 10.9 An Array of Characters Is Not a String

Exceptions

  • 11.1 The Kinds and Causes of Exceptions
  • 11.2 Compile-Time Checking of Exceptions
  • 11.3 Run-Time Handling of an Exception

Execution

12.1 Java Virtual Machine Startup 12.2 Loading of Classes and Interfaces 12.3 Linking of Classes and Interfaces 12.4 Initialization of Classes and Interfaces 12.5 Creation of New Class Instances 12.6 Finalization of Class Instances 12.7 Unloading of Classes and Interfaces 12.8 Program Exit

Binary Compatibility

13.1 The Form of a Binary 13.2 What Binary Compatibility Is and Is Not 13.3 Evolution of Packages and Modules 13.4 Evolution of Classes 13.5 Evolution of Interfaces

Blocks and Statements

14.1 Normal and Abrupt Completion of Statements 14.2 Blocks 14.3 Local Class Declarations 14.4 Local Variable Declaration Statements 14.5 Statements 14.6 The Empty Statement 14.7 Labeled Statements 14.8 Expression Statements 14.9 The if Statement 14.10 The assert Statement 14.11 The switch Statement 14.12 The while Statement 14.13 The do Statement 14.14 The for Statement 14.15 The break Statement 14.16 The continue Statement 14.17 The return Statement 14.18 The throw Statement 14.19 The synchronized Statement 14.20 The try statement 14.21 The yield Statement 14.22 Unreachable Statements

Expressions

15.1 Evaluation, Denotation, and Result 15.2 Forms of Expressions 15.3 Type of an Expression 15.4 FP-strict Expressions 15.5 Expressions and Run-Time Checks 15.6 Normal and Abrupt Completion of Evaluation 15.7 Evaluation Order 15.8 Primary Expressions 15.9 Class Instance Creation Expressions 15.10 Array Creation and Access Expressions 15.11 Field Access Expressions 15.12 Method Invocation Expressions 15.12.1 Compile-Time Step 1: Determine Class or Interface to Search 15.12.2 Compile-Time Step 2: Determine Method Signature 15.12.3 Compile-Time Step 3: Is the Chosen Method Appropriate? 15.12.4 Run-Time Evaluation of Method Invocation 15.13 Method Reference Expressions 15.14 Postfix Expressions 15.15 Unary Operators 15.16 Cast Expressions 15.17 Multiplicative Operators 15.18 Additive Operators 15.19 Shift Operators 15.20 Relational Operators 15.21 Equality Operators 15.22 Bitwise and Logical Operators 15.23 Conditional-And Operator && 15.24 Conditional-Or Operator || 15.25 Conditional Operator ? : 15.26 Assignment Operators 15.27 Lambda Expressions 15.28 switchExpressions 15.29 Constant Expressions

Definite Assignment

16.1 Definite Assignment and Expressions 16.2 Definite Assignment and Statements 16.2.1 Empty Statements 16.2.2 Blocks 16.2.3 Local Class Declaration Statements 16.3 Definite Assignment and Parameters 16.4 Definite Assignment and Array Initializers . . . 16.9 Definite Assignment, Constructors, and Instance Initializers

Threads and Locks

17.1 Synchronization

synchronization

  • is implemented using monitors
  • Each object in Java is associated with a monitor

17.2 Wait Sets and Notification 17.3 Sleep and Yield 17.4 Memory Model 17.4.1 Shared Variables 17.4.2 Actions 17.4.3 Programs and Program Order 17.4.4 Synchronization Order 17.4.5 Happens-before Order 17.4.6 Executions 17.4.7 Well-Formed Executions 17.4.8 Executions and Causality Requirements 17.4.9 Observable Behavior and Nonterminating Executions 17.5 final Field Semantics 17.6 Word Tearing 17.7 Non-Atomic Treatment of double and long

Type Inference

18.1 Concepts and Notation 18.1.1 Inference Variables 18.1.2 Constraint Formulas 18.2 Reduction

The Java® Virtual Machine Specification

Introduction

The Structure of the Java Virtual Machine

2.1 The class File Format 2.2 Data Types 2.3 Primitive Types and Values 2.4 Reference Types and Values 2.5 Run-Time Data Areas 2.6 Frames 2.7 Representation of Objects 2.8 Floating-Point Arithmetic 2.9 Specail Methods 2.10 Exceptions 2.11 Instruction Set Summary 2.12 Class Libraries 2.13 Public Design, Private Implementation

Compiling for the Java Virtual Machine

3.1 Format of Examples 3.2 Use of Constants, Local Variables, and Control Constructs 3.3 Arithmetic 3.4 Accessing the Run-Time Constant Pool 3.5 More Control Examples 3.6 Receiving Arguments 3.7 Invoking Methods 3.8 Working with Class Instances 3.9 Arrays 3.10 Compiling Switches 3.11 Operations on the Operand Stack 3.12 Throwing and Handling Exceptions 3.13 Compiling finally 3.14 Synchronization 3.15 Annotations 3.16 Modules

The class File Format

  • 4.1 The ClassFile Structure
  • 4.2 Names
    • 4.2.1 Binary Class and Interface Names
    • 4.2.2 Unqualified Names
    • 4.2.3 Module and Package Names
  • 4.3 Descriptors
  • 4.4 The Constant Pool
  • 4.5 Fields
  • 4.6 Methods
  • 4.7 Attributes
  • 4.8 Format Checking
  • 4.9 Constraints on Java Virtual Machine Code
  • 4.10 Verification of class Files
  • 4.11 Limitations of the Java Virtual Machine

Loading, Linking, and Initializing

  • 5.1 The Run-Time Constant Pool
  • 5.2 Java Virtual Machine Startup
  • 5.3 Creation and Loading
    • 5.3.1 Loading Using the Bootstrap Class Loader
    • 5.3.2 Loading Using a User-defined Class Loader
    • 5.3.3 Creating Array Classes
    • 5.3.4 Loading Constraints
    • 5.3.5 Deriving a Class from a class File Representation
    • 5.3.6 Modules and Layers
  • 5.4 Linking
    • 5.4.1 Verification
    • 5.4.2 Preparation
    • 5.4.3 Resolution
  • 5.5 Initialization
  • 5.6 Binding Native Method Implementations
  • 5.7 Java Virtual Machine Exit

The Java Virtual Machine Instruction Set

Opcode Mnemonics by Opcode

cache

spring CacheManager

Cache vs Buffer

Spring

Dependency injection/Inversion of Control

Testing

  • Unit Testing
  • Mock Objects

sleep() wait()/notify()

Object o = new Object();
 
"Thread-1" #12 prio=5 os_prio=31 tid=0x00007f90aa20b800 nid=0x5903 waiting on condition [0x000070000b218000] //Thread.sleep(n)
"Thread-0" #11 prio=5 os_prio=31 tid=0x00007f90a91b9000 nid=0x5703 in Object.wait() [0x000070000b115000]  //o.wait();
"main" #1 prio=5 os_prio=31 tid=0x00007f90a901b000 nid=0x2903 waiting on condition [0x00007000099cd000]  //Thread.sleep(n) 

New features in Java 17

  • Enhanced Pseudo-Random Number Generators
English 中文 描述
variables 变量  
Static variables 静态变量 所有实例,能被修改,is stored on the data segment area of memory and the same value is get shared to all instances of that class
Constant variables 常量/恒定变量 每个实例”一份”,但是不能修改值
Static Constant variables 静态常量 所有实例只有“一份”,而且不能修改
Constant pool 常量池 holds all the constants (integer, string, etc.);不是java对象;是在class文件中(loading过程)
String pool string literal 只有string;java对象

Referrence


git

Concept

  • SCM: Software Configuration Management
  • VCS: Version Control Systems

Version Control Systems are just that, software that provides versioning functionality (Git, Subversion, TFS Version Control) all fall into this category.

Software Configuration Management is a broader term that encompasses all the processes needed to build, package, and deploy software – this includes Version Control Systems. It does not refer to software per se.

  • working directory / working tree

Unstaged changes exist in our Working Directory, but Git hasn’t recorded them into its version history yet.

  • index/staged

  • HEAD

a reference to the last commit in the currently checked-out branch.

git diff

git diff View difference between Stage and Working Directory git diff --staged View difference between HEAD and Stage --staged is a synonym of --cached git diff HEAD View difference between HEAD and Working Directory git diff commmit-1 commit-2 View difference between commmit-1 and commmit-2

Conclusion

git-scm What is the difference between git diff HEAD vs. git diff –staged? What’s the difference between VCS and SCM? How to list all the files in a commit? about-collaborative-development-models


crypto,encode,hash

History of Cryptography

  • The earlier Roman method of cryptography, popularly known as the Caesar Shift Cipher
  • Steganography:invisible watermarking.
  1. Caesar Cipher/Shift Cipher(not a secure cryptosystem)
  2. Simple Substitution Cipher
  3. Monoalphabetic and Polyalphabetic Cipher
  4. Playfair Cipher
  5. Vigenere Cipher
  6. Variants of Vigenere Cipher 6.1 One-Time Pad 6.1.1 Shift Cipher − Easy to Break 6.1.2 One-time Pad − Impossible to Break 6.2 Transposition Cipher

Block Ciphers(DES、AES)

  • Feistel Block Cipher (DES)
  • Encryption/Decryption Process
    • Number of Rounds
    • efficiency–security tradeoff
  • AES
    • It is found at least six time faster than triple DES
    • Symmetric key symmetric block cipher
    • 128-bit data, 128/192/256-bit keys
    • Stronger and faster than Triple-DES
    • Provide full specification and design details

Stream Ciphers

Evolution of Cryptography

  • Vigenere Coding
  • the more sophisticated art and science of information security
  • Enigma rotor machine
  • cryptography and cryptanalysis

Security Services of Cryptography

  • Confidentiality
  • Data Integrity: 检测数据是否被修改
  • Authentication

Electronic Code Book (ECB) Mode Analysis of ECB Mode Cipher Block Chaining (CBC) Mode Analysis of CBC Mode Cipher Feedback (CFB) Mode

cryptography & hash function & encoding

cryptography

  • 加解密
  • 加密hash
  • Mac-加密hash

Components of a Cryptosystem

  • Plaintext
  • Encryption Algorithm.
  • Ciphertext
  • Decryption Algorithm
  • Encryption Key
  • Decryption Key

Types of Cryptosystems

  • Symmetric Key : same keys are used for encrypting and decrypting − Digital Encryption Standard (DES), Triple-DES (3DES), IDEA, and BLOWFISH.
  • Asymmetric Key : different keys are used for encrypting and decrypting the information

Challenge of Symmetric Key Cryptosystem

  • Key establishment
  • Trust Issue

Asymmetric Key Encryption

hash function

  • 普通的hash (Non-cryptographic hash functions) MurMurHash. It’s not difficult to reverse from digest to message
  • 加密hash (Unkeyed cryptographic hash functions) MD5/SHA1/SHA256…
  • (Keyed cryptographic hash functions) HMAC

encoding

  • encoding/decoding Base64

encrypted decrypt

HMAC alongside AES (encrypt data)

  • AES is encryption; (Advanced Encryption Standard)
    • 对称加密 symmetric-key algorithm, meaning the same key is used for both encrypting and decrypting the data.
    • key size of 128, 192, or 256 bits
    • original name Rijndael
  • DES Data Encryption Standard (DES)
    • AES 接替 DES
  • cipher

In cryptography, a block cipher is a deterministic algorithm operating on fixed-length groups of bits, called blocks. It uses an unvarying transformation, that is, it uses a symmetric key.

  • HMAC is a nice MAC algorithm

  • Base64
    • 可逆。decodable/reversible. hash不是
    • encode后的字符串长度不定,受原字符串影响。 hash(md5/SHA1/SHA256…)hash后长度一定
  • SHA
    • hash ()
    • Secure Hash Algorithm
    • SHA-1, SHA-256
    • produce digest
  • AES
    • Advanced Encryption Standard
    • 加解密 encrypt/decrypt
  • 加解密
    • 原始串 (plaintext)
    • 秘钥 (key)
    • 加密串(ciphertext)
    • AES/DES
  • 哈希
    • 原始串
    • 哈希后digest
    • md5/SHA1/SHA256/SHA224
  • 哈希-加盐(salt/key)
    • 不加盐,同一hash算法,hash后的串相同
    • 加盐,同一hash算法,相同原串后的串不同
    • HMAC-SHA1/HMAC-md5/HMAC-xxx
    • brute forced/hash collision
  • 编解码(encode/decode)
    • 原始串
    • 编码串
    • Base64 (公开算法,可编解码)

Cryptographic hash function

  • data of arbitrary size (often called the “message”) to a bit array of a fixed size (the “hash value”, “hash”, or “message digest”).
  • one-way function
  • infeasible to invert
  • the only way: brute-force search / use a rainbow table of matched hashes

properties

  • deterministic(确定性):the same message always results in the same hash
  • quick(速度快)
  • infeasible to reverse(不可逆,one way)
  • infeasible to find two different messages with the same hash value(没有2个数据hash是相同的,实际是很少)
  • a small change to a message should change the hash value so extensively(很小的变化,hash value变化很大)

  • 对称加密(symmetric key) & 非对称加密(asymmetric)
    • 对称:DES/AES/Blowfish/Twofish
    • 非对称:RSA/DSA/ECDSA/ED25519
  • Difference between SALT and KEY. Encryption

message authentication codes (MACs) digital signatures / 使用private-key签名,使用public-key验证(verify)

The ideal cryptographic hash function has six main properties:

  • Deterministic: the same message always results in the same hash;
  • Quick: it is quick to compute the hash value for any given message;
  • One-way function: it is infeasible to generate a message from its hash value except by trying all possible messages;
  • Avalanche effect: a small change to a message should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value;
  • Collision resistant: it is infeasible to find two different messages with the same hash value
  • Pre-image attack resistant: a pre-image attack on cryptographic hash functions tries to find a message that has a specific hash value. A cryptographic hash function should resist attacks on its pre-image.

  • hash 分类

    • 普通的hash (Non-cryptographic hash functions) MurMurHash. It’s not difficult to reverse from digest to message
    • 加密hash (Unkeyed cryptographic hash functions) MD5/SHA1/SHA256…
    • (Keyed cryptographic hash functions) HMAC

    • Fixed Length Output (Hash Value) 固定长度输出
    • Efficiency of Operation 速度快,一般都比对称加密快

    • Message Digest (MD)
      • In 2004, collisions were found in MD5.This collision attack resulted in compromised MD5 and hence it is no longer recommended for use.
    • Secure Hash Function (SHA) [14]
      • SHA-0, SHA-1, SHA-2, and SHA-3
      • SHA-1, Secure Socket Layer (SSL) security. In 2005, a method was found for uncovering collisions for SHA-1 within practical time frame making long-term employability of SHA-1 doubtful.
      • SHA-2, No successful attacks have yet been reported on SHA-2 hash function.
      • In October 2012, the NIST chose the Keccak algorithm as the new SHA-3 standard.
    • RIPEMD
    • Whirlpool
  • hash常见应用场景 (Applications of Hash Functions)
    • Password Storage/密码保存
    • Data Integrity Check/数据完整性检查
  • Cryptography

  • information security / 信息安全
    • data confidentiality / 数据保密
    • data integrity / 数据完整性
    • non-repudiation /
    • authentication / 认证
  • jwt 使用

  • MAC 信息传输、保存后,数据的完整性 G (key-generator) gives the key k on input 1n, where n is the security parameter. S (signing) outputs a tag t on the key k and the input string x. V (verifying) outputs accepted or rejected on inputs: the key k, the string x and the tag t.

    • MAC algorithm is a symmetric key cryptographic technique/对称加密技术 [13]
  • hash 和 mac主要解决的应用场景
    • sender提供了message和digest。 receiver已经知道digest,只需要验证message是否被修改。[hash]
    • sender提供了message和digest。 receiver不知道digest,也是通过非安全渠道获取到digest的。如果攻击者,同时修改message和digest,那么receiver就不知道了。 这时使用mac,攻击者如果修改了message,但是不知道key,所以无法修改digest,这样receiver就能验证。[mac]
  • Hashing is a one-way function where data is mapped to a fixed-length value. Hashing is primarily used for authentication
  • Salting is an additional step during hashing, typically seen in association to hashed passwords, that adds an additional value to the end of the password that changes the hash value produced.

  • Difference between salted hash and keyed hashing?

difference-encryption-hashing-salting Difference between salted hash and keyed hashing Encryption, hashing, salting – what’s the difference?

  • Keyed hashing is usually used to build message authentication codes (MACs), the most common of which is the hashed-based MAC (HMAC).
    • secret key
    • should be as fast as possible
    • 防篡改
  • Salted hashing are intended to deter brute-force attacks , they are intentionally designed to be slow.
    • 防暴力攻击(brute-force attacks)
    • designed to be slow
    • salts are not assumed to be secret.
  • 能不能逆转
  • hash 不能
  • 加密 能
  • 逆转是否使用密码
  • 加解密 使用
  • 编解码(encoding/decoding) 不使用

Attacks

  • Passive Attacks : “偷看”未授权的信息
  • Active Attacks:修改信息

casbin

  1. checksum
  2. hash_function
  3. base64
  4. purpose of Base64
  5. CryptoJS-online
  6. [HMAC](https://en.wikipedia.org/wiki/HMAC#:~:text=In%20cryptography%2C%20an%20HMAC%20(sometimes,and%20a%20secret%20cryptographic%20key.)
  7. blockchain
  8. 比特币如何运作
  9. What is Blockchain Hashing?
  10. How does a blockchain work - Simply Explained-Youtube
  11. Cryptographic hash function
  12. mac
  13. Message Authentication
  14. Cryptography Hash functions
  15. Authentication vs. Authorization
  16. rfc6749 Oauth
  17. rfc7519
  18. casbin