1/ How to store passwords safely in the database and how to validate a password? Letโs take a look.
๐๐ก๐ข๐ง๐ ๐ฌ ๐๐๐ ๐ญ๐จ ๐๐จ
๐น Storing passwords in plain text is not a good idea because anyone with internal access can see them.
2/ ๐น Storing password hashes directly is not sufficient because it is pruned to precomputation attacks, such as rainbow tables.
๐น To mitigate precomputation attacks, we salt the passwords.
3/ ๐๐ก๐๐ญ ๐ข๐ฌ ๐ฌ๐๐ฅ๐ญ?
According to OWASP guidelines, โa salt is a unique, randomly generated string that is added to each password as part of the hashing processโ.
4/ ๐๐จ๐ฐ ๐ญ๐จ ๐ฌ๐ญ๐จ๐ซ๐ ๐ ๐ฉ๐๐ฌ๐ฌ๐ฐ๐จ๐ซ๐ ๐๐ง๐ ๐ฌ๐๐ฅ๐ญ?
1๏ธโฃ A salt is not meant to be secret and it can be stored in plain text in the database. It is used to ensure the hash result is unique to each password.
5/ 2๏ธโฃ The password can be stored in the database using the following format: ๐ฉ๐ข๐ด๐ฉ( ๐ฑ๐ข๐ด๐ด๐ธ๐ฐ๐ณ๐ฅ + ๐ด๐ข๐ญ๐ต).
๐๐จ๐ฐ ๐ญ๐จ ๐ฏ๐๐ฅ๐ข๐๐๐ญ๐ ๐ ๐ฉ๐๐ฌ๐ฌ๐ฐ๐จ๐ซ๐?
To validate a password, it can go through the following process:
1๏ธโฃ A client enters the password.
6/ 2๏ธโฃ The system fetches the corresponding salt from the database.
3๏ธโฃ The system appends the salt to the password and hashes it. Letโs call the hashed value H1.
4๏ธโฃ The system compares H1 and H2 (H2 is the hash stored in the database). If they are the same, the password is valid
7/ Over to you: what other mechanisms can we use to ensure password safety?
8/ If you found this thread helpful, follow me @alexxubyte for more.
Retweet the first tweet to help more people to learn system design.
โข โข โข
Missing some Tweet in this thread? You can try to
force a refresh
Hypertext Transfer Protocol Secure (HTTPS) is an extension of the Hypertext Transfer Protocol (HTTP.) HTTPS transmits encrypted data using Transport Layer Security (TLS.) If the data is hijacked online, all the hijacker gets is binary code.
How is the data encrypted and decrypted?
Step 1 - The client (browser) and the server establish a TCP connection.
Step 2 - The client sends a โclient helloโ to the server. The message contains a set of necessary encryption algorithms and the latest TLS version it can support. The server responds with a โserver helloโ so the browser knows whether it can support the algorithms and TLS version.
1/ How to learn design patterns? Besides reading a lot of well-written code, a good book guides us like a good teacher.
๐๐๐๐ ๐ ๐ข๐ซ๐ฌ๐ญ ๐๐๐ฌ๐ข๐ ๐ง ๐๐๐ญ๐ญ๐๐ซ๐ง๐ฌ, second edition, is the one I would recommend.
2/ When I began my journey in software engineering, I found it hard to understand the classic textbook, ๐๐๐ฌ๐ข๐ ๐ง ๐๐๐ญ๐ญ๐๐ซ๐ง๐ฌ, by the Gang of Four. Luckily, I discovered Head First Design Patterns in the school library. This book solved a lot of puzzles for me.
3/ When I went back to the Design Patterns book, everything looked familiar and more understandable.
Last year, I bought the second edition of Head First Design Patterns and read through it. Here are a few things I like about the book:
How does Twitter work? Letโs take a look at it from the architectural point of view before Elon takes it.
๐๐ก๐ ๐๐ข๐๐ ๐จ๐ ๐ ๐๐ฐ๐๐๐ญ:
1๏ธโฃ A tweet comes in through the Write API.
2๏ธโฃ The Write API routes the request to the Fanout service.
3๏ธโฃ The Fanout service does a lot of processing and stores them in the Redis cache.
4๏ธโฃ The Timeline service is used to find the Redis server that has the home timeline on it.
5๏ธโฃ A user pulls their home timeline through the Timeline service.
๐๐๐๐ซ๐๐ก & ๐๐ข๐ฌ๐๐จ๐ฏ๐๐ซ๐ฒ
๐น Ingester: annotates and tokenizes Tweets so the data can be indexed.
๐น Earlybird: stores search index.
๐น Blender: creates the search and discovery timelines.
Popular interview question: What is the difference between ๐๐ซ๐จ๐๐๐ฌ๐ฌ and ๐๐ก๐ซ๐๐๐?
To better understand this question, letโs first take a look at what is a Program.
A ๐๐ซ๐จ๐ ๐ซ๐๐ฆ is an executable file containing a set of instructions and passively stored on disk. One program can have multiple processes. For example, the Chrome browser creates a different process for every single tab.
A ๐๐ซ๐จ๐๐๐ฌ๐ฌ means a program is in execution. When a program is loaded into the memory and becomes active, the program becomes a process. The process requires some essential resources such as registers, program counter, and stack.
Interesting read: Software Architecture and Design InfoQ Trends Report โ April 2022 by @InfoQ
Key takeaways:
โData plus architecture" is the idea that, more frequently, software architecture is adapting to consider data. This holistically includes data quality, data pipelines, and traceability to understand how data influenced decisions and AI models.
Innovative software architecture is facilitating data quality the way weโve improved code quality. Catching bad data early is as important as catching bugs early.
The practice of software architecture does not belong solely to people with the job title of architect.
One picture is worth more than a thousand words. In this post, we will take a look at how to design ๐๐จ๐จ๐ ๐ฅ๐ ๐๐จ๐๐ฌ.
1๏ธโฃ Clients send document editing operations to the WebSocket Server.
2๏ธโฃ The real-time communication is handled by the WebSocket Server.
3๏ธโฃ Documents operations are persisted in the Message Queue.
4๏ธโฃ The File Operation Server consumes operations produced by clients and generates transformed operations using collaboration algorithms.
5๏ธโฃ Three types of data are stored: file metadata, file content, and operations.
One of the biggest challenges is real-time conflict resolution. Common algorithms include:
๐น Operational transformation (OT)
๐น Differential Synchronization (DS)
๐น Conflict-free replicated data type (CRDT)