<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashutosh Mishra on Medium]]></title>
        <description><![CDATA[Stories by Ashutosh Mishra on Medium]]></description>
        <link>https://medium.com/@iashu2k?source=rss-875690abbd4f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vcweWRGCFoYTzn0DWuVGnQ.jpeg</url>
            <title>Stories by Ashutosh Mishra on Medium</title>
            <link>https://medium.com/@iashu2k?source=rss-875690abbd4f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:21:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iashu2k/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[useRef hook in Reactjs | Simplified]]></title>
            <link>https://iashu2k.medium.com/useref-hook-in-reactjs-simplified-c44806f42f2a?source=rss-875690abbd4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c44806f42f2a</guid>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Ashutosh Mishra]]></dc:creator>
            <pubDate>Fri, 30 Apr 2021 14:18:46 GMT</pubDate>
            <atom:updated>2021-04-30T14:18:46.339Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*3d0jsQppieVP5XL6KGK6YA.png" /></figure><p>In this post we’ll cover what the <a href="https://reactjs.org/docs/hooks-reference.html#useref">useRef Hook</a> is, what we can use it for and some advice for using it.</p><p>useRef returns a mutable ref object whose .current property is initialized to the passed argument (initialValue). The returned object will persist for the full lifetime of the component.</p><pre>const refContainer = useRef(initialValue);</pre><p>Keep in mind that useRef <em>doesn’t</em> notify you when its content changes. Mutating the .current property doesn’t cause a re-render.</p><h3>Uses of useRef hook</h3><ol><li><strong>To manipulate DOM elements</strong></li></ol><p>No we’ll not use the focus example :)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f492323adf16dc93f5799a9669c74cf5/href">https://medium.com/media/f492323adf16dc93f5799a9669c74cf5/href</a></iframe><p>Since mutating the <em>.current</em> property doesn’t causes a re-render it can be used to manipulate the elements.</p><p>2. <strong>To store the number of time a component has rendered</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f174af4648d8cd154721496ec8f2b30/href">https://medium.com/media/1f174af4648d8cd154721496ec8f2b30/href</a></iframe><p>3. <strong>To check if a component is mounted or unmounted</strong></p><p>Since <em>.current </em>can be initialized with any value boolean values can be initialized as true and made false in the clean up function to avoid interacting with an unmounted component.</p><p>Similarly functions, objects can also be stored. Just treat it as you would for example a field or instance variable on a class as opposed to something on a state.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c44806f42f2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are WebSockets ?]]></title>
            <link>https://iashu2k.medium.com/what-are-websockets-20322b45989d?source=rss-875690abbd4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/20322b45989d</guid>
            <category><![CDATA[sockets]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[Ashutosh Mishra]]></dc:creator>
            <pubDate>Fri, 30 Apr 2021 11:13:57 GMT</pubDate>
            <atom:updated>2021-04-30T11:13:57.507Z</atom:updated>
            <content:encoded><![CDATA[<h3>What are WebSockets ?</h3><h3><strong>What is a socket?</strong></h3><p>A socket is one endpoint of a two way communication link between a client and a server which can be used to establish a real-time, bidirectional and event-based communication. In simpler terms a socket can be understood with the analogy of a phone. User A has to initiate communication by dialing to User B. Once the call is received a bidirectional channel is established and real time communication becomes possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XOjKAa-eh5jhdck3" /><figcaption>Photo by <a href="https://unsplash.com/@jim_reardan?utm_source=medium&amp;utm_medium=referral">Jim Reardan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>What is a WebSocket?</strong></h3><p>WebSocket is a computer <a href="https://en.wikipedia.org/wiki/Communications_protocol">communications protocol</a>, providing <a href="https://en.wikipedia.org/wiki/Full-duplex">full-duplex</a> communication channels over a single <a href="https://en.wikipedia.org/wiki/Transmission_Control_Protocol">TCP</a> connection.The WebSocket protocol enables interaction between a <a href="https://en.wikipedia.org/wiki/Web_browser">web browser</a> (or other client application) and a <a href="https://en.wikipedia.org/wiki/Web_server">web server</a> facilitating real-time data transfer from and to the server.</p><h3>How are WebSockets different from HTTP?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*qF0R69e8gA_onkxPD8rTxg.png" /></figure><p>In a typical HTTP (http or https) connection a request is sent to and endpoint which returns a response and then the connection closes. This is repeated anytime a communication has to made via HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*IV0hIIaaRgf0xT_f6-hFrQ.png" /></figure><p>In WebSockets (ws or wss) there is a bidirectional communication between WebSockets the sender and receiver both can send data. Whenever a communication is made between client and server a handshake is performed and the connection is opened.Once the connection is open the communication happens in the form of bidirectional messaging. Once the connection is opened it exists until one of the sides(client or server) decides to close the connection. The the connection is terminated from both the ends.</p><p>Uses of WebSockets:-</p><ol><li>Real time applications (ex chat apps, trading apps etc)</li><li>Gaming applications</li></ol><h3>How can you implement sockets in your applications?</h3><p>Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. It consists of:</p><p>1. A Node.js server</p><p>2. A js client library for browsers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*oV8F-DAHI8UmA3-o-T_07A.png" /></figure><h3>Features</h3><p>Here are the features provided by Socket.IO over plain WebSockets:</p><p>· reliability (fallback to HTTP long-polling in case the WebSocket connection cannot be established)</p><p>· automatic reconnection</p><p>· packet buffering</p><p>· acknowledgements</p><p>· broadcasting <a href="https://socket.io/docs/v4/broadcasting-events/">to all clients</a> or <a href="https://socket.io/docs/v4/rooms/">to a subset of clients</a> (what we call “Room”)</p><p>· <a href="https://socket.io/docs/v4/namespaces/">multiplexing</a> (what we call “Namespace”)</p><p>For more read the <a href="https://socket.io/docs/v4">docs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20322b45989d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Message Traceability vs End-to-End Encryption]]></title>
            <link>https://iashu2k.medium.com/message-traceability-vs-end-to-end-encryption-add848ad7159?source=rss-875690abbd4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/add848ad7159</guid>
            <category><![CDATA[technical-analysis]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[technical-writing]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Ashutosh Mishra]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 11:19:51 GMT</pubDate>
            <atom:updated>2020-06-04T11:19:51.618Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TPxQxiIdC7q6KCHV" /><figcaption>Photo by <a href="https://unsplash.com/@jamie452?utm_source=medium&amp;utm_medium=referral">Jamie Street</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>The craze of texting can be seen in the world, we see people texting anytime and anyplace, these texts connect people to their friends, family and relatives. Leaving social texting or comment texting like on twitter or Facebook, where people are somewhat conscious about what they are putting out in public. The real privacy concerns are your WhatsApp chats, these texts are personal and are to the people you trust and you believe, the text written on top i.e.</strong></p><blockquote>“messages to this chat and calls are now secured with end-to-end encryption”</blockquote><p>do hold some weight. People may not realise, but all these chats and smart data algorithm can narrow-down all your thoughts, for example, which movies you like, your political inclination, your support to any cause, your reaction to government policies etc. In the 21st century data is the new oil, the math is simple the more data you have on someone the more you can gain leverage over them.</p><blockquote><a href="https://tech.economictimes.indiatimes.com/news/mobile/india-asks-whatsapp-to-fingerprint-messages-to-ensure-traceability/69833913">In June 2019, the Indian government asked WhatsApp to fingerprint messages to ensure traceability. The government has been insistent in its demand for traceability of WhatsApp messages after misinformation. Similar things can be observed in other parts of the world too.</a></blockquote><blockquote><a href="https://economictimes.indiatimes.com/news/international/world-news/facebook-encryption-threatens-public-safety-priti-patel-tells-zuckerberg/articleshow/71445166.cms?from=mdr">On Sep 2019 reports came that UK government is trying to force WhatsApp and Facebook to share messages with law enforcement agencies. Priti Patel, the U.K.’s home secretary, has previously warned that Facebook’s plan to enable users to send end-to-end encrypted messages would benefit criminals, and called on social media firms to develop “back doors” to give intelligence agencies access to their messaging platforms.</a></blockquote><p>The response from Facebook was “<strong><em>Government policies like the Cloud Act allow for companies to provide available information when we receive valid legal requests and do not require companies to build back doors.</em></strong>”<br>So why should anyone deny access to their chats by the government if they have nothing to hide and all this to “only” bring peace to society and fighting criminals and terror outfits?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*veOA4FU5oCLvdIFS" /><figcaption>Photo by <a href="https://unsplash.com/@anniespratt?utm_source=medium&amp;utm_medium=referral">Annie Spratt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s go a few decades back when the smartphones were not a common thing and SMS prices were still high. In those days too backdoor access existed, since all modes of communication were wired they were known as wiretaps. If in any investigation, there was enough evidence against a person of interest, law enforcement agencies could get a warrant to look into his postal mails, listen to his phone conversations and intercept his text messages. So if the times have changed and backdoor accesses are there from decades, why not extend it to modern techs like Facebook and WhatsApp? In contrast to the phone lines, the modern-day encryption uses complicated mathematics which is easy for a computer to calculate one way but its impossible to calculate in reverse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JDHbAqtjg7Rr9dZV" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For example, if you multiply two prime numbers lets say 17 and 19 the result will be 323 as simple as it looks. Since they were prime numbers we know there is only one way to get 323 by multiplying two whole numbers, now if you try to calculate those numbers 17 and 19 it would be a brute force approach, it will take time and you can’t pinpoint the solution in one go. But for computers, this number is longer than 3-digit. It could be a 15-digit or even more.</p><p><em>This is a simple example modern cryptography can design encryption which can easily encrypt in one way but may take more time than the lifetime of the universe to brute force backwards</em>. The result is that you can have two keys a<strong> public key </strong>and a<strong> private key</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aBJ4QaC0IQ5MwO5U" /><figcaption>Photo by <a href="https://unsplash.com/@1eemingwell?utm_source=medium&amp;utm_medium=referral">Jonas Lee</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A public key can be used by anyone to encrypt data which looks like random noise, even the same public key can’t brute force the messages backwards. When you pass this noise to your private key which only you have you can see the actual message. Unless and until only you have your private key no one else can read your messages. These methods were too complicated and not friendly, so earlier most of the web service chats were unencrypted because the security wasn’t worth the effort. But rapidly companies realised the need for it, so now they use regular web encryption to padlock your browser so that no one on the network can see what you are doing or read your messages in transit. But these companies have your messages stored somewhere in something close to plain text and when a government agency comes with a warrant they can show your messages to them.</p><p>So this was a trade-off between security and usability, until when almost all governments decided to keep that data under their jurisdiction for the national interest. This paved the way for the rise of messaging apps like WhatsApp and Telegram which support “<strong>end-to-end encryption</strong>”. Which means your phone generates a public and a private key for you automatically. Your public keys keep on changing even when you are writing your messages. There can still be some loopholes. Security experts keep checking all versions of such apps to find a possible backdoor entrance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zt0dWENbAqkmE057" /><figcaption>Photo by <a href="https://unsplash.com/@wesleyphotography?utm_source=medium&amp;utm_medium=referral">Wesley Tingey</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In short if today a government agent would barge into WhatsApp with a legal warrant the most he could look at is the statistics on how much the user is chatting and partly his location history but he can’t see what he was talking about. Anything more than this is mathematically impossible. This is how the structure is designed.<br><strong><em>So the only way left with governments to get back door entrance is by outlawing the technology</em></strong>. They can pass laws making it mandatory for companies to share user data or their functioning on the countries soil can be prevented or they could also be banned in that country if they refuse to give backdoor access.</p><p>Back in 2013, the Indian government had full access to user chat and web history on blackberry devices. So why is back door access a bad idea? The reason is simple these companies are global so if a backdoor is given in one country it can be used anywhere in the world. This will cause the other countries, to mass surveillance their adversaries leading to data war among countries. Now, all countries do not enjoy the same level of freedom, what if a private chat in the country shows someone is from LGBTQ or someone is consuming marijuana and in that country, it is banned, this could lead to mass incarnations of innocent civilians under dictatorships and mental or financial harassments or even vote manipulations by micro-targeting individual groups for vote-bank in democracies. To make things even worse the nature of back door also affects its use, if the back door can access not only current but all the previous history from the past. The authorities can profile every citizen and manifest their consciousness into a digital storage device. Just imagine the impact of such access. People make mistakes, they mature according to their time but now due to your profiling, imagine if you supported something but now you disagree with that or a deleted naked picture of you or your love interests in the past, someone having back door access will see your life in the way they want and interpret against you in the way they like. What if a rogue government employee has a personal hatred against you. He can shred your life into pieces. Coming to the government itself what if a foreign intelligence agency started spying on other countries official, imagine the leverage they can gain on a person of interest and the access he possesses can be abused. All this may now start to be feeling like a Hollywood movie, but the real world’s ambiguity can turn this into very much reality. Some countries already use it like China.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cm6EwcRhS6zcJJ5Y" /><figcaption>Photo by <a href="https://unsplash.com/@fearthelocals?utm_source=medium&amp;utm_medium=referral">Parker Coffman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Is all of this 21st-century cold-war worth, in the name of stopping terrorism or stopping fake news the main motive of governments is to gain the modern nuclear weapon i.e. data and a set of eyes on everyone to seize the power of longer duration because they will be able to see what is the mind of their population. To fight terrorism we need more police force and up-gradation in their technology. Moreover, if a terror outfit wants to have a secure communication there are thousands of ways to do so or at the end, they could very much make up their code.</p><blockquote>But this tussle for backdoor access is growing and has even led to outsourcing in espionage, the recent reports of WhatsApp hack by the Israeli company NSO points us in this direction. At first, the idea of backdoor access and fingerprinting messages to its creator for national security looks fairly a good idea, but the devil is in details.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qt6MBz6VciEd0fea" /><figcaption>Photo by <a href="https://unsplash.com/@iambrettzeck?utm_source=medium&amp;utm_medium=referral">Brett Zeck</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=add848ad7159" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>