<?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 Hemant Kumar Singh on Medium]]></title>
        <description><![CDATA[Stories by Hemant Kumar Singh on Medium]]></description>
        <link>https://medium.com/@singhkumarhemant?source=rss-9ea46de6b74------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*fzB7Ee6IPyurNDtJ1NOR4w.jpeg</url>
            <title>Stories by Hemant Kumar Singh on Medium</title>
            <link>https://medium.com/@singhkumarhemant?source=rss-9ea46de6b74------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 00:51:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@singhkumarhemant/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[Arrow Function: What the heck is THIS anyway?]]></title>
            <link>https://medium.com/@singhkumarhemant/arrow-function-what-the-heck-is-this-anyway-c63314732c88?source=rss-9ea46de6b74------2</link>
            <guid isPermaLink="false">https://medium.com/p/c63314732c88</guid>
            <category><![CDATA[arrow-functions]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[this]]></category>
            <dc:creator><![CDATA[Hemant Kumar Singh]]></dc:creator>
            <pubDate>Sat, 18 May 2019 12:50:45 GMT</pubDate>
            <atom:updated>2019-05-30T10:24:52.275Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*h36yQQZa_j2gkZvv.jpeg" /></figure><p>How nice it is to see the evolution of the programming language you code every day. Learning from mistakes, searching for better implementation, creating new features is what makes the progress from version to version.</p><p>This is happening to JavaScript these years when <a href="http://www.ecma-international.org/ecma-262/6.0/">ECMAScript 6</a> brings the language to a new level of usability: arrow functions, classes and a lot more. And this is quite Awesome!</p><p>Arrow Functions are one of the most impactful changes in ES6/ES2015, and they are widely used nowadays,They slightly differ from regular functions. Let’s find out how….</p><h3>So What Are JavaScript Arrow Functions Anyway?</h3><blockquote><em>An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords. Arrow function expressions are ill suited as methods, and they cannot be used as constructors.<br> — </em><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions"><em>MDN web docs</em></a></blockquote><p>So Arrow functions are a more concise syntax for writing function expressions. They utilize a new token, =&gt;, that looks like a fat arrow. They are anonymous and change the way this binds in functions. They make our code prettier and concise and simplify function scoping and the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">this</a> keyword. They are roughly the equivalent of lambda functions in python or blocks in Ruby.</p><p>Let’s look at the syntax:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/0*H7t3wc58P_DN6aTY.gif" /></figure><p>There are a couple of ways to define arrow functions( see <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">MDN</a> ) and I will try to provide a mere overview of each of them.</p><h3>With Multiple Parameters</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/905fb7fb715f218d0d776f27028be6c4/href">https://medium.com/media/905fb7fb715f218d0d776f27028be6c4/href</a></iframe><h3>With One Parameter</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ccd2d38a5c7ec54c9e27b6921ad7280/href">https://medium.com/media/9ccd2d38a5c7ec54c9e27b6921ad7280/href</a></iframe><h3>With No Parameters</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9452fc0da430883f36ac4b9f940b4ba5/href">https://medium.com/media/9452fc0da430883f36ac4b9f940b4ba5/href</a></iframe><h3>Object Literal Syntax</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5827c6f5d3b0696c32ae2dcb21d27ab/href">https://medium.com/media/d5827c6f5d3b0696c32ae2dcb21d27ab/href</a></iframe><h3>Why use Arrow Functions?</h3><p>There are two benefits to arrow functions.</p><p>First, they are less verbose than traditional function expressions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c6e7f98eb18ab08e6a0166913862c4e/href">https://medium.com/media/1c6e7f98eb18ab08e6a0166913862c4e/href</a></iframe><p>Second, their this is picked up from surroundings ( <em>lexical</em>). Therefore, you don&#39;t need bind() or that = this, anymore. see this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8b8f72d9776d3befffb017207a268c2/href">https://medium.com/media/f8b8f72d9776d3befffb017207a268c2/href</a></iframe><h3>When use Arrow Functions?</h3><p>When I first came across ES6, I found arrow functions really coooool but I was little confused until I got <a href="http://exploringjs.com/es6/ch_arrow-functions.html#sec_traditional-functions-bad-non-methods">this</a> wonderful explanation from <a href="http://exploringjs.com/es6.html"><strong>Exploring ES6</strong></a> (A book by Dr. Axel Rauschmayer).</p><p>While getting a better understanding of arrow functions I somewhere felt an urge to share the experience with those who face the same challenge. Sooo Guys, this is how it goes ==&gt;</p><p>In Javascript, functions always have their own this but that also blocking us to access the this of the surrounding method from inside a callback.</p><p>let&#39;s see this..</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0a0f360140016b8891fe56d09811f28/href">https://medium.com/media/d0a0f360140016b8891fe56d09811f28/href</a></iframe><p>Here are actual o/p is different from what we have expected. this is because the value of this in function (2) and function (3) are the same and they are pointing to global space. that&#39;s why we are getting &quot;Hello&quot; instead of &quot;Welcome&quot;.</p><p>See the demo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/0*PhQwzamaSQcKh2Vk.png" /></figure><p>Well In ES5 we can deal with this problem in 3 ways.</p><h4>Solution 1: that = this</h4><p>We can assign this to a variable that isn&#39;t shadowed. That&#39;s what&#39;s done in line (1), below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bc0a51f6f9a2a3038ea30c1f2d25261/href">https://medium.com/media/4bc0a51f6f9a2a3038ea30c1f2d25261/href</a></iframe><p>See the o/p.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/0*cjzi3OPfzFQu6gm5.png" /></figure><h4>Solution 2: specifying a value for this</h4><p>See the last parameter in line (1).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc770c3627731d7765f07f9de59f64c9/href">https://medium.com/media/bc770c3627731d7765f07f9de59f64c9/href</a></iframe><p>See the o/p.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/0*f9hY61hsN87bhuNf.png" /></figure><h4>Solution 3: bind(this)</h4><p>We can use the bind() method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f04f62fa5add3c495d20cf810e6e9a7/href">https://medium.com/media/4f04f62fa5add3c495d20cf810e6e9a7/href</a></iframe><p>See the o/p.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/0*BetchrPja6AmLyqM.png" /></figure><p>Now see the ES6 solution.</p><h4>ES6 solution: arrow functions</h4><p>Arrow Functions are shorter in syntax and their this is picked up from surroundings ( <em>lexical</em>).</p><p>Now see above code in ES6.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df069ed602ec02444f838f41a7626995/href">https://medium.com/media/df069ed602ec02444f838f41a7626995/href</a></iframe><p>See the o/p.</p><p>Apart from above example, An extremely common example of arrow functions is to pull out a particular value of an object. see the code.</p><pre>const names = objects.map(object =&gt; object.name);</pre><p>Also,</p><pre>const words = [&#39;India&#39;, &#39;RUSSia&#39;, &#39;USA&#39;,&#39;chiNA&#39;];</pre><pre>const downcasedWords = words.map(word =&gt; word.toLowerCase());</pre><p>Another place where arrow functions can make code cleaner and more intuitive is in -Promises and Promise Chains. see example.</p><pre>this.doSomethingAsync().then((result) =&gt; { <br>   this.storeResult(result); <br>});</pre><p>So remember Arrow functions best used with anything that requires this to be bound to the context, and not the function itself.</p><h3>When avoid Arrow Functions?</h3><p>Arrow functions are neat but are not suitable for all use cases. here we will see some of the cases where we should avoid fat arrow =&gt;.</p><h3>With Object Methods</h3><pre>const player = {<br> points: 50, <br> score: () =&gt; {<br> this.points++; <br> } <br>}</pre><p>Here we have our method called score, and whenever we call player.score, it should add one to our points, which is currently 50.</p><p>Now If we run player.score(); a few times, lets say 10 times. then points should be 60.But if I call player, points is still at 50. this is because of arrow functions and this.</p><h3>2. With Object prototype</h3><pre>function Welcome(greeting) { <br> this.greeting = greeting; <br>} </pre><pre>Welcome.prototype.welcomeTeam = () =&gt; { <br>  console.log(this === window); // true <br>  return this.greeting; <br>}; </pre><pre>var wel = new Welcome(&#39;Hello&#39;); <br>wel.welcomeTeam(); // =&gt; undefined</pre><p>Try to do the same with normal function. and you will get the o/p.</p><h3>3. In Callback functions with dynamic context</h3><p>If you use arrow functions in these locations, that dynamic binding will not work, and you may get very confused as to why things aren’t working as expected.</p><pre>var button = document.getElementById(&#39;myButton&#39;); button.addEventListener(&#39;click&#39;, () =&gt; { <br>console.log(this === window); // true <br>this.innerHTML = &#39;i got clicked&#39;; // will not work <br>});</pre><p><strong>this.innerHTML</strong> is equivalent to <strong>window.innerHTML</strong> and has no sense. use normal function here and see the magic.</p><h3>4. When it makes your code less readable</h3><h3>5. While Invoking constructors</h3><pre>var Message = (text) =&gt; {<br>this.text = text; <br>};<br> <br>// Throws &quot;TypeError: Message is not a constructor&quot; <br>var myMessage = new Message(&#39;Hiii Guys!&#39;);</pre><h3>Still Confused???</h3><p>See this wonderful chart by <a href="https://github.com/getify/You-Dont-Know-JS">You Don’t Know JS</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/0*CwiPk42cGGJk_s-p.png" /></figure><h3>Conclusion</h3><p>So I think Arrow functions are a phenomenal addition to the JavaScript, and they are definitely useful.</p><p>arrowFunctions =&gt; &quot;much cleaner and concise code&quot;</p><p>Without a doubt, the arrow function is a great addition. However, like every other feature, they have pros and cons. We should use them as another tool in our toolchest.</p><h3>Before you go…</h3><p>Thanks for reading!</p><p>If you enjoyed this article, please hold down the clap button below 👏 to help others find it. The longer you hold it, the more claps you give!</p><p>And do not hesitate to share your thoughts in the comments below.</p><p>Hope this was helpful.</p><p>Like this article? Follow<a href="https://twitter.com/hemantjava/"> @hemantjava on Twitter</a></p><p>Thanks to @ <a href="https://twitter.com/panzerdp">panzerdp</a> and @ <a href="https://twitter.com/kyleapennell">kyleapennell</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c63314732c88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding SSH and It’s Workflow]]></title>
            <link>https://medium.com/@singhkumarhemant/understanding-ssh-and-its-workflow-3170671ddbc8?source=rss-9ea46de6b74------2</link>
            <guid isPermaLink="false">https://medium.com/p/3170671ddbc8</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[securedataexchange]]></category>
            <category><![CDATA[hashing]]></category>
            <dc:creator><![CDATA[Hemant Kumar Singh]]></dc:creator>
            <pubDate>Fri, 19 Apr 2019 17:50:58 GMT</pubDate>
            <atom:updated>2019-04-29T07:37:41.193Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding SSH and Its Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*LeqiCTUkQMm-f3Uc.png" /></figure><p>For a while, all I knew about SSH was that it helped me out connect to remote servers. I tried many times in the past to become more informed about how it actually works under the hood.</p><p>Sadly I didn’t get anything much and was really stuck..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/0*S1G4oQ9cqIzcfwq5.gif" /></figure><p>But after months of unavoidable exposure to it, things happened to click, and I finally obtained something fruitful.<br>SSH is quite an interesting protocol in itself. A lot of people are using it for secure communication between two machines. It first appeared in the mid-’90s as a sort of replacement for the way of connecting to the remote machine over the internet. Before SSH we were using telnet, rlogin, FTP and so on to connect with remote machines.<br>All this stuff ( telnet, rlogin, FTP) is working perfectly fine but they transmitted all the data in the clear over the network. so if we logged into a remote machine anyone with the packet sniffer between client and the remote machine could see everything we were doing on there. for better understanding see the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/0*Ew56dEgaWDrErIoL.PNG" /></figure><p>So, In 1995, Tatu Ylönen CEO and founder of SSH Communications Security, developed a protocol called SSH to sort of encrypt the data so that no one can see how and what was being sent over the wire(network). This short clip provides an introduction, how ssh discovered.</p><h3>What is SSH?</h3><p>SSH (Secure Shell) is a cryptographic network protocol (rules for transferring encoded data over the network) that allows computers to securely communicate with one another. The physical locations of the computers on both ends of an SSH connection don’t matter provided that the computers are connected to the accessible network and have SSH set up properly. SSH is typically used via the command line however there are certain graphical user interfaces that allow you to use SSH in a more user-friendly manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*YqNQVAxACNpDDVfV.jpeg" /></figure><h3>How Does SSH Work?</h3><p>SSH protocol uses symmetric encryption, asymmetric encryption, and hashing in order to establish a secure connection between two machines(client &amp; Server). The SSH connection between the client and the server happens in four steps:</p><ol><li>Client contacts server to initiate a connection.</li><li>The server responds by sending the client a public cryptography key.</li><li>The server negotiates parameters and opens a secure channel for the client.</li><li>The user, through their client, logs into the server.</li></ol><p>So till now we probably have a basic understanding of how SSH works. The SSH protocol employs a client-server model to authenticate two parties and encrypt the data between them. now we will see how data is being sent under the hood using ssh.</p><p>So what ssh does is, it breaks the data down into a series of packets and just like any packet transfer these things have a few fields at the beginning. so at the top, we define the packet length. these are 4 bytes saying that the packet is that big.</p><p>After that, we have another byte, which tells us how much padding we have got. so till now we have got the packet length and we have got the how much padding there is and then we mention the data we want to share- the payload.</p><p>After that, we have the padding that follows that payload. these are just random bytes they don’t mean anything but they sort of force the encryption harder to detect what’s going on because we have got random data in these. We can also apply compression to the payload if we want to do that and then the whole packet(excluding the packet length) is encrypted.</p><p>The algorithm used for the encryption and for the message authentication code is selected by the server and the client. they establish that at the beginning. so they are established by the client and the server. so it can vary from connection to connection.<br>At the other end, data is decrypted by the server.</p><p>For a better understanding of this data flow, see the image given below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/0*nut2ApHNSOg5XUSQ.png" /></figure><h3>Generate SSH Key</h3><p>If you are setting up a new machine, first generate a key to the default `~/.ssh/id by running:</p><pre>ssh-keygen -t rsa ssh-add ~/.ssh/id_rsa</pre><blockquote>The created key is a private key you should never share with anyone. A public key ~/.ssh/id_rsa.pub will also be created.</blockquote><h3>Conclusion</h3><p>Hope this was clear enough to make you understand the basics of SSH. There are many more details I didn’t mention. We just glanced over the ones that matter the most as a beginner.</p><h3>Before you go…</h3><p>Thanks for reading!</p><p>If you enjoyed this article, please hold down the clap button below 👏 to help others find it. The longer you hold it, the more claps you give!</p><p>And do not hesitate to share your thoughts in the comments below.</p><p>Hope this was helpful.</p><p>Like this article? Follow<a href="https://twitter.com/hemantjava/"> @hemantjava on Twitter</a></p><p><em>Originally published at </em><a href="https://www.agilecaterpillar.com/blog/ssh-and-its-workflow/"><em>https://www.agilecaterpillar.com</em></a><em> on April 19, 2019.</em></p><p>Thanks to <a href="https://twitter.com/computer_phile"><strong>@</strong>computer_phile</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3170671ddbc8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>