<?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>DEV Community: lambert-naaman</title>
    <description>The latest articles on DEV Community by lambert-naaman (@lambstar).</description>
    <link>https://dev.to/lambstar</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%2F1000447%2Fd5a40958-cac2-40ea-ae71-b3c0d2b82c43.jpg</url>
      <title>DEV Community: lambert-naaman</title>
      <link>https://dev.to/lambstar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lambstar"/>
    <language>en</language>
    <item>
      <title>Basic End To End Encryption With Crypto</title>
      <dc:creator>lambert-naaman</dc:creator>
      <pubDate>Wed, 15 Feb 2023 10:26:35 +0000</pubDate>
      <link>https://dev.to/lambstar/basic-end-to-end-encryption-with-crypto-2gh7</link>
      <guid>https://dev.to/lambstar/basic-end-to-end-encryption-with-crypto-2gh7</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hello everyone, today we’ll look at encryption and its sibling, decryption using JavaScript.&lt;br&gt;
Before we dive in, lets understand how end to end systems work in general. For this consider the diagram below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fo7o85z26sciosmyajqug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fo7o85z26sciosmyajqug.png" alt="Image description" width="554" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So user A wants to send some classified information to user B over the Net, but due to trust issues user A decides to encode this information in a format only user B can decode.&lt;br&gt;
Here in our diagram user A and user B agree on what algorithm they will use, then they generate a public/private key-pair and publish their public keys on the internet (server ). This way both user A and B get to keep their private keys private in order to make this system valid.&lt;br&gt;
To encode some information, user A takes user B’s public key from the server and scrambles the original information with this public key then sends the scrambled junk to user B over the internet. &lt;br&gt;
this scrambled data could be passing through an insecure, public network infrastructure within the reach of hackers, but because of this encoding its content become resistant to tampering. Once this scrambled data gets to user B’s end, it is decoded with user B’s private key. All subsequent communications between user A and B follow these procedures. conclusively we can admit that the goal of end to end encryption is to secure communication by ensuring that only the intended recipient can access the message.&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementing End-To-End Encryption In Node.js
&lt;/h2&gt;

&lt;p&gt;In this tutorial we will use the built-in crypto module within Node.js, which has quit a number of cryptographic functions for developers.&lt;br&gt;
So our first step would be to generate a pair of public/private keys which will be used to encrypt and decrypt the data.&lt;/p&gt;

&lt;p&gt;To generate the keys, we will use the generateKeyPairSync() method, which generates a pair of keys using the RSA algorithm. Here's an example code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const crypto = require('crypto');

const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
  modulusLength: 4096,
  publicKeyEncoding: {
    type: 'spki',
    format: 'pem'
  },
  privateKeyEncoding: {
    type: 'pkcs8',
    format: 'pem'
  }
});

console.log('Public Key:\n', publicKey);
console.log('Private Key:\n', privateKey);`

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we used the generateKeyPairSync() method to generate a pair of keys using the RSA algorithm with a modulus length of 4096 bits. &lt;br&gt;
We then use the publicKeyEncoding and privateKeyEncoding options to specify the format of the keys. We also applied the PEM format, which is quit popular for storing keys.&lt;/p&gt;
&lt;h2&gt;
  
  
  Encrypting And Decrypting Our Data
&lt;/h2&gt;

&lt;p&gt;After generating our keys, we want to use them to encrypt and decrypt some data, so lets assume our data is the string “ Naaman Lambert is for Jesus”, lets encrypt and decrypt that data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const crypto = require('crypto');

const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
  modulusLength: 4096,
  publicKeyEncoding: {
    type: 'spki',
    format: 'pem'
  },
  privateKeyEncoding: {
    type: 'pkcs8',
    format: 'pem'
  }
});

const message = “ Naaman Lambert is for Jesus”;
console.log('Original Message:\n', message);

const encryptedMessage = crypto.publicEncrypt(publicKey, Buffer.from(message));
console.log('Encrypted Message:\n', encryptedMessage.toString('base64'));

const decryptedMessage = crypto.privateDecrypt(privateKey, encryptedMessage);
console.log('Decrypted Message:\n', decryptedMessage.toString());`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Observe something in the crypto.publicEncrypt function, the second parameter is ‘buffer.from(message)’ which creates a new instance of a buffer object and loads it with the binary data of the provided message parameter.&lt;br&gt;
So once you’ve hit that run button you should get an output similar to this:&lt;/p&gt;

&lt;p&gt;In the above example, we generated the key pairs first, then we define some hard coded message which we wish to encrypt. Then we apply the publicEncrypt() method to encrypt this message using the public key, afterward we print the encrypted message to the console.&lt;/p&gt;

&lt;p&gt;For decryption we use the privateDecrypt() method to decrypt the message, using the generated private key and the encrypted message as parameters. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>cryptography</category>
      <category>rsa</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Coming back to programming after a long break.</title>
      <dc:creator>lambert-naaman</dc:creator>
      <pubDate>Fri, 20 Jan 2023 08:38:30 +0000</pubDate>
      <link>https://dev.to/lambstar/coming-back-to-programming-after-a-long-break-31ll</link>
      <guid>https://dev.to/lambstar/coming-back-to-programming-after-a-long-break-31ll</guid>
      <description>&lt;p&gt;Hey folks!, hope your all having some nice time!. its been ages since I lay fingers to keys despite the thrilling moments I once had with the bits. started programming on one foot not sure if its the right or wrong foot, but sure I did start with much enthusiasm. not long I started taking separate paths with my new found love. but guess what? we just had a peace talk saying NO TO DIVORCE.  Now we got stronger wings plus some kick boxing skills picked up from the streets, wait, did I say kick boxing?, sure I did and will be glad to show you some moves as we progress. so fasten that seat belt and grab same coffee as we dive.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Why do people abandon programming ?
&lt;/h2&gt;

&lt;p&gt;Ever wondered why folks flee from programming aka coding?, well I think I got some tips that might answer to that question. below are few of the many reasons people leave programming.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;fear of programming logics.&lt;/li&gt;
&lt;li&gt;impatience.&lt;/li&gt;
&lt;li&gt;divided attention/focus&lt;/li&gt;
&lt;li&gt;poor commitment and guide&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where do I start ?
&lt;/h2&gt;

&lt;p&gt;So am assuming you had a rethink and want to give programming a second try, great choice and below are some hints you can follow to get right back on track with your coding career. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;clearly defining your aims and objectives&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Truth is you have to decide what you want to achieve with your programming skill. failure to clearly define this will usually result in a journey with several directions and targets. and this is common amongst novice programmers &lt;br&gt;
who lack professional mentorship. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;knowing what language best suites your need&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every language is nice and learnable but every language don't fix problems the same way. so get a language that solves your kind of problem in the simplest way possible and stick to it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Getting development tools up and running&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What development environment best supports your work?, for me I think visual studio code works just fine. but you might have a different opinion based on your taste of tools. so its best you learn from experts on how to get that tool up and running.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Getting the right materials for learning&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The quality of your work will mostly depend on the quality of knowledge gathered, so its good to make intensive research and try out new stuff. one way to start is by following programming communities like Github, Dev.to, Youtube, Freecodecamp, etc.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Living above your barriers&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Its nice to recognize ones limiting factor(s) as it helps you prepare for worst cases. so first figure out your barrier then work out a plan how to beat that barrier and keep moving forward.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I get going ?
&lt;/h2&gt;

&lt;p&gt;Once you've followed and applied all the above hints you want to know what's next!, below is a verified solution that will send you into the programmers heaven!.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pick a favorable learning pattern&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;some persons learn by watching other developers build projects while others may prefer hand written tutorials. try to discover an approach that works best for you and stick to it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set achievable goals&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;learn to start small I think a good  route would be taking up small projects and online challenges usually designed to enlighten and broaden your experience level. so go fix a couple &lt;br&gt;
of challenges and sharpen your claws.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Learn, code, and code some more&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;without much emphasis, I believe every professional out there was once a novice. what makes the difference is experience plus a solid knowledge base acquired over spacetime.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Participate in online coding communities&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;well I think the best place for evaluation is engaging in online coding challenges and forums. this way you get to observe how others work and compare contrast their skills with yours.&lt;br&gt;
you can find some online coding platforms like hackathon, discord, dev.to, hackernoon, freecodecamp, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  how do I make money with programming ?
&lt;/h2&gt;

&lt;p&gt;wondering how to make some coins with your new found skill?, you could try the following to bag some good fortune with your programming skill.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;API development&lt;/li&gt;
&lt;li&gt;mobile application development&lt;/li&gt;
&lt;li&gt;web application development&lt;/li&gt;
&lt;li&gt;blockchain development&lt;/li&gt;
&lt;li&gt;game development&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;wow, congrats my young fellow and welcome to an all new adventure, where you are totally in charge of the wheels. if you've checked and applied the above rules then I believe your on the right track to that big dream of yours. sooner or later you'll become a master of the art. well, sit tight as we progress to the next phase of a programmers life.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
  </channel>
</rss>
