<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Akash Srivastava</title>
    <description>The latest articles on Forem by Akash Srivastava (@dev1721).</description>
    <link>https://forem.com/dev1721</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F368067%2F7bdfea1c-9413-452f-b4bb-ad9bc87d66a2.jpeg</url>
      <title>Forem: Akash Srivastava</title>
      <link>https://forem.com/dev1721</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dev1721"/>
    <language>en</language>
    <item>
      <title>🎄 Unwrap the Secrets of System Design This Christmas! 🎅</title>
      <dc:creator>Akash Srivastava</dc:creator>
      <pubDate>Wed, 25 Dec 2024 05:27:25 +0000</pubDate>
      <link>https://forem.com/dev1721/unwrap-the-secrets-of-system-design-this-christmas-4ah1</link>
      <guid>https://forem.com/dev1721/unwrap-the-secrets-of-system-design-this-christmas-4ah1</guid>
      <description>&lt;p&gt;The holiday season is here, and what better way to celebrate than by diving into the fascinating world of system design? Whether you're a developer gearing up for your next big project, a tech enthusiast curious about scalable systems, or a designer looking to understand the backbone of digital experiences, this is your perfect chance to level up.  &lt;/p&gt;

&lt;p&gt;I’ve handpicked &lt;strong&gt;5 exclusive system design topics&lt;/strong&gt; that will give you a behind-the-scenes look at the tech powering our modern world. Let’s unwrap this festive knowledge together!  &lt;/p&gt;




&lt;h3&gt;
  
  
  🎁 &lt;strong&gt;1. &lt;a href="https://www.linkedin.com/pulse/high-level-system-design-end-to-end-messaging-chat-like-srivastava-cvybc/?trackingId=5cJnHtTD59VSB28E4xI%2BRQ%3D%3D" rel="noopener noreferrer"&gt;Message System&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Have you ever wondered how platforms like WhatsApp, Slack, or Telegram deliver messages in an instant, no matter where the sender or receiver is? This guide reveals:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The architecture of message queues.
&lt;/li&gt;
&lt;li&gt;Strategies to achieve low latency and high availability.
&lt;/li&gt;
&lt;li&gt;Techniques to handle peak traffic without breaking a sweat.
&lt;/li&gt;
&lt;li&gt;Best practices for ensuring message delivery and fault tolerance.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mastering message systems equips you to build communication platforms that users can trust.  &lt;/p&gt;




&lt;h3&gt;
  
  
  🎁 &lt;strong&gt;2. &lt;a href="https://www.linkedin.com/pulse/high-level-system-design-scalable-efficient-any-akash-srivastava-0ltmc/?trackingId=WKrXLf3F5MocUJdmS4PAmg%3D%3D" rel="noopener noreferrer"&gt;Notification System&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Notifications are the heart of user engagement—but delivering them efficiently is a challenge. This guide will help you understand:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building a notification pipeline that supports multiple channels (email, push, SMS).
&lt;/li&gt;
&lt;li&gt;Optimizing delivery schedules to maximize user engagement.
&lt;/li&gt;
&lt;li&gt;Scaling your system to handle millions of notifications daily.
&lt;/li&gt;
&lt;li&gt;Managing failures and ensuring retries for guaranteed delivery.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Get ready to create notification systems that are timely, reliable, and scalable.  &lt;/p&gt;




&lt;h3&gt;
  
  
  🎁 &lt;strong&gt;3. &lt;a href="https://www.linkedin.com/pulse/how-design-scalable-url-shortener-system-walkthrough-akash-srivastava-qqmvc/?trackingId=PvnQGJTPsiQ224p%2FFpaaag%3D%3D" rel="noopener noreferrer"&gt;URL Shortener&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;What makes those tiny URLs so mighty? Systems like Bitly may seem simple, but their design is anything but basic. Dive into:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Designing algorithms for unique, collision-free short URLs.
&lt;/li&gt;
&lt;li&gt;Choosing the right database structure for billions of mappings.
&lt;/li&gt;
&lt;li&gt;Handling scalability for viral links and massive traffic spikes.
&lt;/li&gt;
&lt;li&gt;Adding analytics features to track URL performance.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guide will give you a comprehensive understanding of building a robust URL shortener service.  &lt;/p&gt;




&lt;h3&gt;
  
  
  🎁 &lt;strong&gt;4. &lt;a href="https://www.linkedin.com/pulse/designing-cloud-storage-system-like-google-drive-akash-srivastava-xjocc/?trackingId=6%2FRF%2B3H%2F6Q%2F3b97sTVxkVg%3D%3D" rel="noopener noreferrer"&gt;Cloud Storage like Drive&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Cloud storage is at the core of our digital lives. Learn how systems like Google Drive and Dropbox ensure seamless access and security with:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Distributed file storage and data replication techniques.
&lt;/li&gt;
&lt;li&gt;Scalable metadata management for millions of files.
&lt;/li&gt;
&lt;li&gt;Implementing robust encryption for data security.
&lt;/li&gt;
&lt;li&gt;Ensuring high availability and fault tolerance.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Peek behind the curtain and see what makes cloud storage systems reliable and efficient.  &lt;/p&gt;




&lt;h3&gt;
  
  
  🎁 &lt;strong&gt;5. &lt;a href="https://www.linkedin.com/pulse/system-design-modern-generative-ai-chatbot-akash-srivastava-35hjc/?trackingId=tQ7ggD%2BUhu9%2FTjJJ387MgQ%3D%3D" rel="noopener noreferrer"&gt;Generative AI Chatbot&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Generative AI is transforming how we interact with technology. Want to build your own intelligent chatbot? This guide covers:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understanding natural language processing (NLP).
&lt;/li&gt;
&lt;li&gt;Architecting a conversational AI system using embeddings and large language models (LLMs).
&lt;/li&gt;
&lt;li&gt;Optimizing your chatbot for real-time interactions.
&lt;/li&gt;
&lt;li&gt;Balancing creativity and factual grounding in responses.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end of this guide, you’ll know how to create a chatbot that feels almost human.  &lt;/p&gt;




&lt;h3&gt;
  
  
  🎄 Why System Design Matters
&lt;/h3&gt;

&lt;p&gt;System design isn’t just a buzzword; it’s the backbone of everything we build. Whether you’re preparing for a technical interview, scaling a real-world application, or working on side projects, understanding these principles will set you apart.  &lt;/p&gt;




&lt;h3&gt;
  
  
  ✨ Your Festive Learning Journey Awaits
&lt;/h3&gt;

&lt;p&gt;This Christmas, gift yourself the power of knowledge. Grab your favorite holiday drink, explore these guides, and start building systems that inspire confidence and drive innovation.  &lt;/p&gt;

&lt;p&gt;🎅 &lt;strong&gt;Wishing you a merry, meaningful, and tech-filled holiday season.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Let’s make this Christmas one to remember!  &lt;/p&gt;

&lt;p&gt;If you are interested in Mock Interviews on System Design then you can book a slot with me on &lt;a href="https://topmate.io/erakashsrivastava/1352398" rel="noopener noreferrer"&gt;topmate.io&lt;/a&gt;. For more posts like this, follow &lt;a href="//www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&amp;amp;followMember=akash-srivastava-public"&gt;Er. Akash Srivastava&lt;/a&gt; and get insightful content like this.&lt;/p&gt;

&lt;p&gt;Follow me at all Social: &lt;a href="https://linktr.ee/er.akash.srivastava" rel="noopener noreferrer"&gt;er.akash.srivastava&lt;/a&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>ai</category>
      <category>aws</category>
      <category>node</category>
    </item>
    <item>
      <title>Do you wanna keep your embedded database encrypted?</title>
      <dc:creator>Akash Srivastava</dc:creator>
      <pubDate>Mon, 04 Oct 2021 02:58:41 +0000</pubDate>
      <link>https://forem.com/dev1721/do-you-wanna-keep-your-embedded-database-encrypted-5egk</link>
      <guid>https://forem.com/dev1721/do-you-wanna-keep-your-embedded-database-encrypted-5egk</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Data privacy and security is the priority of every software product and services. During developing any software product or services as a developer first thing we should have to keep in mind that the storage and fetching of data should be secured and protected. &lt;br&gt;
In this blog I am using SQLite Database and Python Language to show how to encrypt Data inside database and how to show the decrypted data on client side.&lt;br&gt;
I am dividing the process into several parts to get good understanding.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understanding of Data Encryption&lt;/li&gt;
&lt;li&gt;Software Setup&lt;/li&gt;
&lt;li&gt;Core Coding Understanding&lt;/li&gt;
&lt;li&gt;Inferences &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Theory of Data Encryption
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Theory
&lt;/h3&gt;

&lt;p&gt;Encryption is the process of translating plain text data (plaintext) into something that appears to be random and meaningless (ciphertext). Decryption is the process of converting ciphertext back to plaintext.&lt;br&gt;
To encrypt more than a small amount of data, symmetric encryption is used. A symmetric key is used during both the encryption and decryption processes. To decrypt a particular piece of ciphertext, the key that was used to encrypt the data must be used.&lt;br&gt;
The goal of every encryption algorithm is to make it as difficult as possible to decrypt the generated ciphertext without using the key. If a really good encryption algorithm is used, there is no technique significantly better than methodically trying every possible key. For such an algorithm, the longer the key, the more difficult it is to decrypt a piece of ciphertext without possessing the key.&lt;br&gt;
It is difficult to determine the quality of an encryption algorithm. Algorithms that look promising sometimes turn out to be very easy to break, given the proper attack. When selecting an encryption algorithm, it is a good idea to choose one that has been in use for several years and has successfully resisted all attacks.&lt;br&gt;
&lt;a href="https://docs.microsoft.com/en-us/windows/win32/seccrypto/data-encryption-and-decryption" rel="noopener noreferrer"&gt;Reference&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Flow Diagram
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tgdxclbonzxzo4no0u8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tgdxclbonzxzo4no0u8.png" alt="image" width="800" height="266"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Software Setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Tool: VS-Code: &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;Download&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Language: Python &lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;Download&lt;/a&gt;, SQLite &lt;a href="https://www.sqlite.org/download.html" rel="noopener noreferrer"&gt;Download&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Libraries: Cryptography Command: &lt;code&gt;pip install cryptography&lt;/code&gt;-&lt;a href="https://pypi.org/project/cryptography/" rel="noopener noreferrer"&gt;Read Here&lt;/a&gt;,
Fernet &lt;a href="https://cryptography.io/en/latest/fernet/" rel="noopener noreferrer"&gt;Read Here&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Core Coding
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Scenario to understand Coding
&lt;/h3&gt;

&lt;p&gt;Let us take a part of application which maintains the daily routine of ours in a database embedded in our system. But there is a risk of keeping the &lt;code&gt;.db&lt;/code&gt; file in the system as plain text because the data is readable. So, we have to keep this database encrypted hence we will use following method to encrypt the data base.&lt;/p&gt;

&lt;h4&gt;
  
  
  File Structure and Understanding
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9r1bf4p9bksm8k9gwre7.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9r1bf4p9bksm8k9gwre7.JPG" alt="filestructure" width="216" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will be using modular form development. So for each functionality we will be creating a module. And finally use each module in main module by importing and calling it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Creation of Database
&lt;/h4&gt;

&lt;p&gt;As shown there is a file name &lt;code&gt;createdb.py&lt;/code&gt;.The purpose of this file is to create a new database &lt;code&gt;mySecret.db&lt;/code&gt; having following columns: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routine ID: It is the description of routine such as morning routine, breakfast, office hour etc.&lt;/li&gt;
&lt;li&gt;Date: The date when this routine is or was happened.&lt;/li&gt;
&lt;li&gt;Start Time: The time when this routine is starting/started.&lt;/li&gt;
&lt;li&gt;End Time: The time when this routine is ending/ended.&lt;/li&gt;
&lt;li&gt;Status: The Routine is done/pending/in progress/not done etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Steps
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Create a file name as &lt;code&gt;createdb.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Code the program as shown in Python Code to implement the db creation.&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h6&gt;
  
  
  Python Code to implement the db creation
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sqlite3

def create():
    conn = sqlite3.connect("mySecret.db")
    crsr = conn.cursor()
    sql_command = """CREATE TABLE ROUTINE (
    routineID VARCHAR(10000) PRIMARY KEY,
    date DATE,
    startTime VARCHAR(5),
    endTime VARCHAR(5),
    status VARCHAR(10));"""
    crsr.execute(sql_command)
    conn.commit()
    conn.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Code Explanation
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;sqlite3&lt;/code&gt; is the library we have to import in order to work with database in python.&lt;br&gt;
Every Database handling under sqlite3 follows simple process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connection with database&lt;/li&gt;
&lt;li&gt;Taking the curser of database&lt;/li&gt;
&lt;li&gt;Giving the SQL Query to Execute&lt;/li&gt;
&lt;li&gt;Commit the Execution&lt;/li&gt;
&lt;li&gt;Closing the Database. &lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  SQL Query to create Table
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE ROUTINE (
routineID VARCHAR(10000) PRIMARY KEY,
date DATE,
startTime VARCHAR(5),
endTime VARCHAR(5),
status VARCHAR(10));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Generation of Universal Key
&lt;/h4&gt;

&lt;p&gt;As shown there is a filename &lt;code&gt;generateKey.py&lt;/code&gt;.The purpose of this file is to generate a universal key which would be use while encryption and decryption of a cell in database.&lt;/p&gt;

&lt;h5&gt;
  
  
  Steps
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Create a file name as &lt;code&gt;generateKey.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Code the program as shown in Python Code to implement the key generation.&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h6&gt;
  
  
  Python Code to implement the key generation
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from cryptography.fernet import Fernet

def generate():
    key = Fernet.generate_key()
    with open("universal.key","wb") as key_files:
        key_files.write(key)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Code Explanation
&lt;/h5&gt;

&lt;p&gt;Fernet is the library from Cryptography which is being used in this code to generate the key which we will be using as universal key as of now. The generated key is stored in the file &lt;code&gt;universal.key&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Process of Encrypting Data
&lt;/h4&gt;

&lt;p&gt;As shown there is a filename &lt;code&gt;encrypt.py&lt;/code&gt;.The purpose of this file is to encrypt the secret message passed as parameter.&lt;/p&gt;

&lt;h5&gt;
  
  
  Steps
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Create a file name as &lt;code&gt;encrypt.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Code the program as shown in Python Code to implement the encryption.&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h6&gt;
  
  
  Python Code
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from cryptography.fernet import Fernet

def loadKey():
    key = open("universal.key","rb").read()
    return key

def Encrypt(secret):
    key = loadKey()
    encodeSecret = secret.encode()
    fer  = Fernet(key)
    return fer.encrypt(encodeSecret)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Code Explanation
&lt;/h5&gt;

&lt;p&gt;Fernet is the library from Cryptography which is being used in this code to encrypt the data. We will made a block name &lt;code&gt;loadKey()&lt;/code&gt; which will load the universal key stored inside the &lt;code&gt;universal.key&lt;/code&gt;. Then we will make an &lt;code&gt;Encrypt()&lt;/code&gt; block accepting "secret" as the parameter. For encryption we will first encode the secret message then pollute it with the salt made by &lt;code&gt;Fernet(key)&lt;/code&gt;by encrypting with the encoded message.&lt;/p&gt;

&lt;h4&gt;
  
  
  Process of Decrypting Data
&lt;/h4&gt;

&lt;p&gt;As shown there is a filename &lt;code&gt;decrypt.py&lt;/code&gt;.The purpose of this file is to decrypt the encrypted message passed as parameter.&lt;/p&gt;

&lt;h5&gt;
  
  
  Steps
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Create a file name as &lt;code&gt;decrypt.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Code the program as shown in Python Code to implement the decryption.&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h6&gt;
  
  
  Python Code
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from cryptography.fernet import Fernet

def loadKey():
    key = open("universal.key","rb").read()
    return key

def Decrypt(encryptSecret):
    key = loadKey()
    fer  = Fernet(key)
    decryptSecret = fer.decrypt(encryptSecret)
    return decryptSecret.decode()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Code Explanation
&lt;/h5&gt;

&lt;p&gt;Fernet is the library from Cryptography which is being used in this code to decrypt the data. We will made a block name &lt;code&gt;loadKey()&lt;/code&gt; which will load the universal key stored inside the &lt;code&gt;universal.key&lt;/code&gt;. Then we will make an &lt;code&gt;Decrypt()&lt;/code&gt; block accepting "encryptSecret" as the parameter. For decryption we will first depollute the secret message from the salt made by &lt;code&gt;Fernet(key)&lt;/code&gt;by decrypting with the encrypted message then decode it to view the original secret message.&lt;/p&gt;

&lt;h4&gt;
  
  
  Data Entry of encrypted data to database.
&lt;/h4&gt;

&lt;p&gt;As shown there is a file name &lt;code&gt;dataentry.py&lt;/code&gt;.The purpose of this file is to insert encrypted data into the database &lt;code&gt;mySecret.db&lt;/code&gt; having following columns: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routine ID: It is the description of routine such as morning routine, breakfast, office hour etc.&lt;/li&gt;
&lt;li&gt;Date: The date when this routine is or was happened.&lt;/li&gt;
&lt;li&gt;Start Time: The time when this routine is starting/started.&lt;/li&gt;
&lt;li&gt;End Time: The time when this routine is ending/ended.&lt;/li&gt;
&lt;li&gt;Status: The Routine is done/pending/in progress/not done etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Steps
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Create a file name as &lt;code&gt;dataentry.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Code the program as shown in Python Code to implement data entry of encrypted data.&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h6&gt;
  
  
  Python Code
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sqlite3
import encrypt 

def enter(id,dt,st,et,status):
    conn = sqlite3.connect("mySecret.db")
    crsr = conn.cursor()
    sql_command = """INSERT INTO ROUTINE(routineID,date,startTIme,endTime,status)
    VALUES (?,?,?,?,?);"""
    id = encrypt.Encrypt(id)
    dt = encrypt.Encrypt(dt)
    st = encrypt.Encrypt(st)
    et = encrypt.Encrypt(et)
    status = encrypt.Encrypt(status)

    tup = (id,dt,st,et,status)
    crsr.execute(sql_command,tup)
    conn.commit()
    conn.close()  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Code Explanation
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;sqlite3&lt;/code&gt; is the library we have to import in order to work with database in python. And we are also importing 'encrypt' module made by us.&lt;br&gt;
Every Database handling under sqlite3 follows simple process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connection with database&lt;/li&gt;
&lt;li&gt;Taking the curser of database&lt;/li&gt;
&lt;li&gt;Giving the SQL Query to Execute&lt;/li&gt;
&lt;li&gt;Commit the Execution&lt;/li&gt;
&lt;li&gt;Closing the Database. 
The &lt;code&gt;enter()&lt;/code&gt; block takes 5 parameters as input. And then encrypt each parameter and then insert into the db in the form of tuple as shown in the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  SQL Query to insert into db
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO ROUTINE(routineID,date,startTIme,endTime,status)
    VALUES (?,?,?,?,?);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Printing of Decrypted data
&lt;/h4&gt;

&lt;p&gt;As shown there is a file name &lt;code&gt;dataprinting.py&lt;/code&gt;.The purpose of this file is to print decrypted data from the database &lt;code&gt;mySecret.db&lt;/code&gt; having following columns: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routine ID: It is the description of routine such as morning routine, breakfast, office hour etc.&lt;/li&gt;
&lt;li&gt;Date: The date when this routine is or was happened.&lt;/li&gt;
&lt;li&gt;Start Time: The time when this routine is starting/started.&lt;/li&gt;
&lt;li&gt;End Time: The time when this routine is ending/ended.&lt;/li&gt;
&lt;li&gt;Status: The Routine is done/pending/in progress/not done etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Steps
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Create a file name as &lt;code&gt;dataprinting.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Code the program as shown in Python Code to implement data printing of decrypted data.&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h6&gt;
  
  
  Python Code
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sqlite3
import decrypt

def printit():
    conn = sqlite3.connect("mySecret.db")
    crsr = conn.cursor()
    crsr.execute("SELECT * FROM ROUTINE")
    rows = crsr.fetchall()
    for row in rows:
        for cell in row:
            print(decrypt.Decrypt(cell))

    conn.commit()
    conn.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Code Explanation
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;sqlite3&lt;/code&gt; is the library we have to import in order to work with database in python. And we are also importing 'decrypt' module made by us.&lt;br&gt;
Every Database handling under sqlite3 follows simple process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connection with database&lt;/li&gt;
&lt;li&gt;Taking the curser of database&lt;/li&gt;
&lt;li&gt;Giving the SQL Query to Execute&lt;/li&gt;
&lt;li&gt;Commit the Execution&lt;/li&gt;
&lt;li&gt;Closing the Database. 
The &lt;code&gt;printit()&lt;/code&gt; fetch all rows(tuple) of database. And then decrypt each cell of each tuple and then print it. &lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  SQL Query to select all elements
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM ROUTINE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Main Module
&lt;/h3&gt;

&lt;h5&gt;
  
  
  Steps
&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Create a file name as &lt;code&gt;main.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Code the program as shown in Python Code.&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h6&gt;
  
  
  Python Code
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from os import path
import createdb
import generateKey
import dataentry
import dataprinting

def main():
    if(path.exists('mySecret.db')==False):
        generateKey.generate()
        createdb.create()
    exit = int(input("enter 0 if you want to exit or 1 to continue entring data"))
    while(exit==1):
        id = input("input routineID")
        dt = input("input date in DD-MM-YYYY")
        st = input("input start time in hh:mm")
        et = input("input end time in hh:mm")
        status = input("not done/pending/inprogress/done")
        dataentry.enter(id,dt,st,et,status)
        exit = int(input("enter 0 if you want to exit or 1 to continue entering data"))
    dataprinting.printit()

main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Code Explanation
&lt;/h5&gt;

&lt;p&gt;We are importing &lt;code&gt;path from os&lt;/code&gt;, self made modules &lt;code&gt;createdb&lt;/code&gt;,&lt;code&gt;generateKey&lt;/code&gt;,&lt;code&gt;dataentry&lt;/code&gt;and&lt;code&gt;dataprinting&lt;/code&gt;. The purpose of &lt;code&gt;path&lt;/code&gt; is to check whether the database 'mySecret.db' already exists or not. If it is not exist we will create the db and generate one universal key otherwise leave these two steps as shown in the &lt;code&gt;main()&lt;/code&gt; block. Now we are asking user to select either 1 "if they want to insert data in db" or 0 "if they do not want to insert data in db". Then in while loop we are taking 5 inputs and entering in database using module &lt;code&gt;dataentry&lt;/code&gt;.Once the data is being entered control comes out of while loop and using module &lt;code&gt;dataprinting&lt;/code&gt; print the data.&lt;/p&gt;

&lt;h5&gt;
  
  
  Code Run
&lt;/h5&gt;

&lt;p&gt;Once you run &lt;code&gt;main.py&lt;/code&gt; the code it will ask &lt;code&gt;enter 0 if you want to exit or 1 to continue entering data'. Click 1 and enter insert all data as asked. once all rows are finished press 0 to exit out of loop. And all the data will be printed. But in behind the scene some process happened.&lt;/code&gt;mySecret.db` and 'univeral.key' are created.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Output &lt;br&gt;
&lt;strong&gt;Universal Key&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;yn1ZrHZ2VBLqq7iZ38pTMvRf9-3pyAVHFlWjADIPO20=&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Consider below image to open db&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxhoygu41jqxi059lq52.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxhoygu41jqxi059lq52.JPG" alt="opendb" width="388" height="557"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Data inside DB:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;routineID&lt;/th&gt;
&lt;th&gt;date&lt;/th&gt;
&lt;th&gt;startTime&lt;/th&gt;
&lt;th&gt;endTime&lt;/th&gt;
&lt;th&gt;status&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gAAAAABhWDfTHxfYmU4kHl9uSqt-bF0LpSlZZyxyk2cXbyummG0HRfLRH6Ouja8u7yt12Ii-qAHzX_hkohLhg9GKglzEZhT2Hg==&lt;/td&gt;
&lt;td&gt;gAAAAABhWDfTh4WTHW0ezh8kpWnr7Ccs5ZvdI12jtbxVRKa4pmKOx-Fm6cZ1NGbV_uTkk9--GG97LEjUSEEPRN-8Cj3RYtWSjQ==&lt;/td&gt;
&lt;td&gt;gAAAAABhWDfTeGHg8foPNYIZxchL61UDmORidKvFgvdy_eiBX8vEV-24qk5fTrjinehW51AAs3ZZHWN3R-tvnJdfUpcykvMpsg==&lt;/td&gt;
&lt;td&gt;gAAAAABhWDfTNFTmf7Cxgc48IUmrrKakT4-CSi4FYLp57DTzlqy3s9TFuEKXpIAPRa2gNWif_vO2Nc_6_Na1CpmvdrHNRdaTZQ==&lt;/td&gt;
&lt;td&gt;gAAAAABhWDfT_hCJYgSVWZjCTy3YqWyhvORmVDi4tS4EZHsHJLe6P3t4ljZRFro21eFKemOnK9SZh3uzl7NOM7c54nDTBEQkSg==&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gAAAAABhWDhKooyIOnSHEJWhkj8QUaNw1YPIPzxyYHUE7yoBGWsIDlVy5_s7_SJPnF6yj5kxf_Lykl6SwYpVRMNbmJ9dGU7NkA==&lt;/td&gt;
&lt;td&gt;gAA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t;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F492g6u48x9yadhzwomsh.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F492g6u48x9yadhzwomsh.JPG" alt="print" width="485" height="832"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Inference
&lt;/h2&gt;

&lt;p&gt;Hence, the blog concludes with the demonstration of understanding of Data base encryption using Python and SQLite.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By Akash Srivastava&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do Follow me on&lt;/em&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/akash-s-233ab3160/" rel="noopener noreferrer"&gt;[LinkedIn]&lt;/a&gt;&lt;a href="https://github.com/AkashSrivastava1721" rel="noopener noreferrer"&gt;[GitHub]&lt;/a&gt;&lt;a href="https://twitter.com/AkashSr1234" rel="noopener noreferrer"&gt;[Twitter]&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>sqlite</category>
      <category>hacktoberfest</category>
      <category>security</category>
    </item>
  </channel>
</rss>
