<?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 Caseyjramirez on Medium]]></title>
        <description><![CDATA[Stories by Caseyjramirez on Medium]]></description>
        <link>https://medium.com/@caseyjramirez5?source=rss-a28254ce6946------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*CaGGkTWLywGLLky_</url>
            <title>Stories by Caseyjramirez on Medium</title>
            <link>https://medium.com/@caseyjramirez5?source=rss-a28254ce6946------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:12:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@caseyjramirez5/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[How does Encryption work?]]></title>
            <link>https://medium.com/@caseyjramirez5/what-is-encryption-716d71b1d669?source=rss-a28254ce6946------2</link>
            <guid isPermaLink="false">https://medium.com/p/716d71b1d669</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[encryption]]></category>
            <dc:creator><![CDATA[Caseyjramirez]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 01:18:51 GMT</pubDate>
            <atom:updated>2022-10-25T15:12:50.384Z</atom:updated>
            <content:encoded><![CDATA[<p>Encryption is the process of utilizing algorithms, or rule-based calculations, to turn plain text into what is known as cipher text. Cipher text is essentially garbage, a random assortment of jibberish to the untrained eye, or more accurately unauthorized eye, but more on that to come. Only when cipher text has been deciphered can it be read.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PbtzyIg1A6U7nz8z" /><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>At its most basic level encryption works something like this: I give you a set of instructions such as turn H into Z, turn E into L, turn L into Y, turn O into X, and so on, and so forth... If I wanted to send you a message that said “Hello” I would use these instructions to generate the cipher text “Zlyyx”. You would then use these same instructions backwards to decipher my encrypted message back to “Hello”. Notice how only you, the intended receiver is able to make sense of what is being sent. This is the magic of encryption, it hides messages from unauthorized users. This is especially useful for something like the internet where sensitive information like credit cards, cat names, and SSNs are constantly being broadcasted across networks.</p><p>The method I described earlier is known as single-key or symmetric-key encryption. And though fun for childhood note passing it presents a unique problem. single-key encryption requires both you and me to meet in advance and decide upon a set of rules for encryption/decryption. Practically speaking this wouldn’t be possible if were was a server in San Fransisco sending sensitive information to you, a client in say New York.</p><p>Enter into the scene… Public Key Encryption. Public Encryption utilizes the RSA algorithm to generate two keys that are mathematically linked to one another. One key is a public key and is to be shared with the whole world. While the other one is a private key that is to be kept a secret. So now back to our example from earlier. If you wanted to send me a message that said “Hello” you would first encrypt this message with my public key, remember you, and everyone else has access to this key. Once encrypted this message can only be decrypted by my private key. Therefore, only I the intended receiver, have the authorization to read your message. This is fantastic because it eliminates the need for a prior meeting between you the sender and me the receiver.</p><p>Now let&#39;s say I, the receiver have decrypted your message using my private key and wanted to send you a response. To do so I would encrypt my message using my private key. Once encrypted, this message can only be decrypted using my public key. Now you might be thinking to yourself, what is the point in that? Doesn’t everyone have access to my public key? Yes true, however, if a message is able to be decrypted by my public key then it was encrypted by my…. You guessed it, private key. The one that only I have access to. Thus, authenticating me as the sender, not some phony trying to play me.</p><p>But this leaves one final problem that we need to address. If I only encrypted a message with my private key (authenticating me as the sender) then anyone with access to my public key can decipher that message. Not do we need to authenticate me as the sender but also ensure that you are the only authorized receiver. I would do this by not only encrypting my message with my private key but also your public key. This way I am authenticated as the sender and only you the receiver are able to decipher my message using your private key.</p><p>The art of encryption is far more complex and nuanced than the brief explanation I just gave. To be frank, some of these complexities are still above my head. Encryption is a phenomenal thing that allows our modern world to function. Without encryption, we wouldn’t be able to send/receive sensitive and crucial information across globe in milliseconds via the internet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=716d71b1d669" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[So what’s up with SQL injection attacks?]]></title>
            <link>https://medium.com/@caseyjramirez5/so-whats-up-with-sql-injection-attacks-36bf862a7650?source=rss-a28254ce6946------2</link>
            <guid isPermaLink="false">https://medium.com/p/36bf862a7650</guid>
            <dc:creator><![CDATA[Caseyjramirez]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 13:23:27 GMT</pubDate>
            <atom:updated>2022-10-04T13:23:27.247Z</atom:updated>
            <content:encoded><![CDATA[<p>A SQL injection attack is a web application attack where a malicious user will modify their input to tamper with the performed SQL. The result is an “injected” SQL query that manipulates access to sensitive data or even deletes application data. Oftentimes this data is valuable information such as passwords or credit card information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*X3pOrtfMPB2Qz3H9.jpg" /></figure><p><strong>How do SQL injections work?</strong></p><p>SQL injections work by using user input fields to talk with the database with SQL logic to access data that sbouldnt be accessed. Let&#39;s say for example we wanted to retrieve all order information for a user with the id of 42. Our query would look something like the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*uFfymdTF3SBXpNkX4wkEPw.png" /></figure><p>But, what if instead of simply inserting their user id a malicious user inserts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*dd9tdZAifqCBE-7tntzFgw.png" /></figure><p>This would execute the following query:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*gDNBVGJRTxK5pZlcwcRKZg.png" /></figure><p>Because 1 = 1 will always be true this query will return order data for all users. See, there is no need to break anything — without proper sanitation, hackers can just use logic that is already in place to retrieve sensitive information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*ZBqNtQartqROF-Sf.jpg" /></figure><p><strong>How to prevent SQL injection attacks</strong></p><p>The cardinal rule for preventing SQL injections is to never trust the user. User inputs should never be used directly to construct SQL queries. Let&#39;s look at an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*obgpGFNtOXqQuhUWUFzKAw.png" /></figure><p>Here there are two major optimizations that can be made. First, passing strings as parameters should be avoided, instead user arrays or hashes. In addition, avoid using the user input directly, rather it should be passed as a parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*DPSjpmA701g8fsj2hPrLCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*V0YtLaYUJO70s_M8.jpg" /></figure><p><strong>Think of how you are implementing queries.</strong></p><p>Thinking of how queries are implemented really shaped how I view the process of mitigating the risk of SQL injection. Take a look at the following query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*NhbeiHtPjEwbJjlJewWlfA.png" /></figure><p>As we know, find_by works by applying some specifications to a query and returning the first record that matches the specified condition. This example is over-obvious but nonetheless, a user could provide some always true condition, such as 1=1 to return data in an unintended way. Here it would be better to use a more specific query method such as .where or even an attribute-based equivalent such as .find_by_id to have a query method that works in a more predictable manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*p-Jiyb-AR5iYVrdQ.jpg" /></figure><p><strong>Conclusion:</strong></p><p>As our time of exploring the wonderful world of SQL injections comes to an end there are some key thoughts I want to leave with you.</p><ol><li>SQL injections have never been about “breaking” anything — but rather injection attacks use the logic already present to make your application perform in undesired ways.</li><li>Never trust your user (sorry users). Be sure to sanitize all their inputs. And never use them to build queries directly</li><li>Think of how you are using querying methods. Is it possible for a malicious user to utilize this method in an undesired way?</li><li>Last but definitely not least, Stock photos of hackers are hilarious.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/0*3f5ZXoOeXYcgVKpm.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36bf862a7650" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Where should state and logic be stored?]]></title>
            <link>https://medium.com/@caseyjramirez5/where-should-state-and-logic-be-stored-f014e051aa9e?source=rss-a28254ce6946------2</link>
            <guid isPermaLink="false">https://medium.com/p/f014e051aa9e</guid>
            <dc:creator><![CDATA[Caseyjramirez]]></dc:creator>
            <pubDate>Tue, 13 Sep 2022 14:25:10 GMT</pubDate>
            <atom:updated>2022-09-13T14:25:10.657Z</atom:updated>
            <content:encoded><![CDATA[<p>State is used to store dynamic data that will change over time as users interact with our app. Naturally, as our apps become more complex so will our code source. Take, for example, GoodReads, a social media app for bookworms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d46BZ1eP_7IwcDMMc9RdJQ.png" /></figure><p>We could imagine the component tree for this page would look something like the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FCY-jm66b8o7AKzK8AIFPw.png" /></figure><h3>Which of these components would need state?</h3><p>Not all of these components will need their own state and/or logic. When deciding if a component will need state to function properly there are three good questions we should asking ask ourselves.</p><ol><li>Can the needed data be passed down from a parent via props?</li><li>Can the needed data be computed based on any other state or props in your component?</li><li>Does the needed data remain unchanged over time?</li></ol><p>If the answer to all of these questions is no, then there is cause for state. However, state should only be used if necessary.</p><h3>An Example</h3><p>Take, for example, the navbar. The job of the navbar is to navigate the user to the correct part of a website or application. All a navbar does is points in the right direction. The needed data to do this could easily be hardcoded or even passed down from the parent for a dynamic experience.</p><p>However, what about, the search bar? The search bar takes a query from the user which is then used to filter the results shown on the search feed. Because of this tight coupling between query and feed, both components will need access to the data. To enable this functionality we’ll need to put this state in the <em>most immediate ancestor</em> of the two, which in our case is the Application component. This would look something like the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QsnsSyqGemLJQpRWiwYRew.png" /></figure><h3>Information Flow</h3><p>Say, for example, we wanted to give users the ability to favorite a book in their feed. This logic would need to be stored in the Application component. right? However, what if our application becomes super complex over time? As I’m sure you can imagine our application component will become flustered with state and logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJwlsKmbuYyfW4HugNfp-A.png" /></figure><p>To implement this logic we would not only need to update the data on the frontend but also persist that data on the backend of the application. The code to implement this functionality would look something like the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*p9oYFmeZdXSbdqBf8WkG0w.png" /></figure><p>This code snippet sends a PATCH request to a provided URL. Upon successfully completing, we’ll receive the updated object back from the database. We’ll then use this object to filter through all of our books objects stored in the books state and replace the correct corresponding object with the response object from the database. With this implementation, we are first updating this data in the database and then updating the frontend in one simple sweep.</p><p>However, our current implementation poses two problems.</p><ol><li>This code tightly bonds our book object to its parent. What if we wanted to use this object in a different context outside of the current parent? We’d then have to repeat this code to create the same kind of functionality. This is not only annoying but poses new problems should we encounter a bug</li><li>This code is also super noisy. Imagine if we had dozens of objects we needed to implement the same logic for in the parent component.</li></ol><p>To fix both of these problems we can move some of this code to the child component, which would look something like the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*aODiT7hQPbK8VUJQtXZh6Q.png" /></figure><p>With this code in the child component, we will only need to implement a few lines of code at the parent component level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*r7aXLqU5bji-lRj76HgPxg.png" /></figure><h3>Conclusion</h3><p>With our new implementation, we are handling all backend logic within our Search Item Component and only leaving our Application component the job of updating the front end. This new implementation not only reduces the code necessary on the Application level, it also decouples the Search Feed Component and the Application Component increasing modularity within the application. We can keep the backend code within the Search Feed Item Component because we can safely assume the logic for updating the backend will remain consistent no matter the context of implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f014e051aa9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Which function should I use?]]></title>
            <link>https://medium.com/@caseyjramirez5/which-function-should-i-use-9b0110097ab1?source=rss-a28254ce6946------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b0110097ab1</guid>
            <dc:creator><![CDATA[Caseyjramirez]]></dc:creator>
            <pubDate>Tue, 23 Aug 2022 15:04:58 GMT</pubDate>
            <atom:updated>2022-08-23T15:04:58.067Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HaVF_8gkz0OxfPsnrHX57g.jpeg" /></figure><p>A function is a piece of code written by developers to execute a certain task. Instead of having to rewrite code each time that task arrises, Developers write that code once and call upon it later. In 2015 the way we use and write functions in JavaScript was changed forever by the introducing of anonymous functions known as Arrow Functions. But why were Arrow Functions introduced, and how are they different from traditional functions?</p><p>Besides the obvious difference in syntax, Arrow Functions differ from traditional functions in many ways. The most notable, and what we are going to focus on today is scope. In programming scope refers to the context and accessibility of variables in code.</p><p>In JavaScript we can use the word this to refer to different objects depending on how <em>this</em> is scoped when it is invoked. A good way to think about the this keyword is as a pointer to the parent object. For example, imagine we had a simple function to log the value of this to the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ud56rA9RCv2bEK8vNBy0eQ.png" /></figure><p>Hmmmmm, that’s odd! The this we are calling is found inside of the logThis() function. Therefore, shouldn’t this point to logThis() as its parent object? What’s happening here is that we are calling logThis() without wrapping it in any other code exposing, this to the global object (the window).</p><p>So what if we we wrote the same function inside of a parent object as a method?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mX3ZsGizE-OXpbFeyK0O-g.png" /></figure><p>Now, because we are invoking the logThis() method as a child of the parentObj this will be scoped to point to the parentObj.</p><p>However, what if we called our function wrapped inside of another function? Where would our this keyword point then?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SH-ptqLP8T0Y6GWYcbjhlQ.png" /></figure><p>Hmmmm, why does wrapping our logCarType() method inside of a setTimeout() function return undefined for our car type? That is because when we wrap logCarType() inside of setTimeOut() we are performing a simple invocation. It is almost as if we are calling logCarType apart from the caseysCar object. This results in undefined being retuning. Now we could bind our this keyword to our newly created object telling our setTimeout() function which object to associate the this keyword to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLTX6uaJ7_b4g7Yg0XF1JQ.png" /></figure><p>Now we are telling our setTimeout function, “hey — when you call our logCarType method inside of our Car object I want you to do so in the context of our new caseysCar object”. However this code is noisy and imagine if we had to bind our method each time we wanted to call it. Luckily there is a better way!</p><p>This is where Arrow functions enter the scene. Unlike traditional functions, whose scope is dependent on invokation, arrow functions are scoped lexically. This is means that their scope will always point the the parent object in which whey were written in, no matter how they are called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWIn0eG5JkMDovl__-WuIA.png" /></figure><p>This is the real advantage to arrow functions. So which is better to use is dependent upon how you plan to use the function. While the this value inside a regular function is dynamically scoped dependent upon how you call it. This inside the arrow function is bound lexically to its parent object and will always equal this of the outer function.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b0110097ab1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>