<?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: Ray Jones Muiruri</title>
    <description>The latest articles on Forem by Ray Jones Muiruri (@rayjonesmuiruri).</description>
    <link>https://forem.com/rayjonesmuiruri</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%2F1477444%2F84563601-bfca-4155-b3ee-e16ec8343325.jpg</url>
      <title>Forem: Ray Jones Muiruri</title>
      <link>https://forem.com/rayjonesmuiruri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rayjonesmuiruri"/>
    <language>en</language>
    <item>
      <title>How RSA Works (for Dummies)</title>
      <dc:creator>Ray Jones Muiruri</dc:creator>
      <pubDate>Tue, 14 Oct 2025 23:31:45 +0000</pubDate>
      <link>https://forem.com/rayjonesmuiruri/how-rsa-works-for-dummies-43ja</link>
      <guid>https://forem.com/rayjonesmuiruri/how-rsa-works-for-dummies-43ja</guid>
      <description>&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%2F8rlouwgtzlrir7p1sxjf.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%2F8rlouwgtzlrir7p1sxjf.png" alt=" " width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;RSA stands for &lt;strong&gt;Rivest Shamir Adleman&lt;/strong&gt;, and it was invented by:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ron Rivest&lt;/li&gt;
&lt;li&gt;Adi Shamir&lt;/li&gt;
&lt;li&gt;Leonard Adleman&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;RSA comes from the first letters of their last names.&lt;/p&gt;




&lt;p&gt;There are &lt;strong&gt;2 types of encryption algorithms&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Symmetric&lt;/li&gt;
&lt;li&gt;Asymmetric&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Symmetric encryption algorithms&lt;/strong&gt; use &lt;strong&gt;one key&lt;/strong&gt; to encrypt and decrypt.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Asymmetric encryption algorithms&lt;/strong&gt; use &lt;strong&gt;two keys&lt;/strong&gt; — a &lt;strong&gt;public&lt;/strong&gt; key and a &lt;strong&gt;private&lt;/strong&gt; key.&lt;/p&gt;

&lt;p&gt;RSA works by creating a pair of “commutative keys” — meaning if you encrypt with one, you can decrypt with the other.&lt;/p&gt;

&lt;p&gt;In RSA, if you use the &lt;strong&gt;public key&lt;/strong&gt; to encrypt, you must use the &lt;strong&gt;private key&lt;/strong&gt; to decrypt (and vice versa).&lt;/p&gt;


&lt;h3&gt;
  
  
  RSA Math
&lt;/h3&gt;

&lt;p&gt;Let's look at the mathematics behind RSA.&lt;br&gt;&lt;br&gt;
Here are the basic math concepts you need to know first:&lt;/p&gt;


&lt;h3&gt;
  
  
  0. Basic Math Operations
&lt;/h3&gt;

&lt;p&gt;You should know how addition (+), subtraction (-), multiplication (×), and division (÷) work.&lt;/p&gt;


&lt;h3&gt;
  
  
  1. Factor
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;factor&lt;/strong&gt; — numbers you multiply to get the original number.&lt;br&gt;&lt;br&gt;
If &lt;code&gt;N&lt;/code&gt; is the original number, and multiplying &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; gives you &lt;code&gt;N&lt;/code&gt;, then &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; are factors of &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N = 12
1 * 12 = 12
2 * 6  = 12
3 * 4  = 12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Factors of 12: 1, 2, 3, 4, 6, 12&lt;/p&gt;

&lt;p&gt;Now for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N = 7
1 * 7 = 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Factors of 7: 1, 7&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Prime
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;prime number&lt;/strong&gt; is a number that has only two factors: &lt;strong&gt;1 and itself.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
So from the example above, 7 is prime because its only factors are 1 and 7.&lt;/p&gt;

&lt;p&gt;Other prime numbers: 2, 3, 5, 11, 13, 29, 37, 61, ...&lt;/p&gt;


&lt;h3&gt;
  
  
  3. Semi-Prime
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;semi-prime number&lt;/strong&gt; is a number whose factors are both prime numbers.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;21 = 3 * 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here 3 and 7 are both prime numbers.&lt;br&gt;&lt;br&gt;
So 21 is a semi-prime. &lt;/p&gt;

&lt;p&gt;Note:&lt;br&gt;
We exclude 1 and the number itself since they are common factors in every number.&lt;/p&gt;


&lt;h3&gt;
  
  
  4. Modulo
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Modulo&lt;/strong&gt; just means &lt;em&gt;the remainder after division.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The symbol for modulo is &lt;code&gt;%&lt;/code&gt; (or sometimes &lt;code&gt;MOD&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7 % 3 = 1   → because 3*2=6 and 7-6=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So 1 is the remainder (modulo).&lt;/p&gt;

&lt;p&gt;You can think of it as: &lt;em&gt;what’s left over after dividing.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;So that’s the 5 basic math concepts you need.&lt;br&gt;&lt;br&gt;
But as we go along, I’ll introduce another one that combines them.&lt;/p&gt;


&lt;h3&gt;
  
  
  RSA Algorithm
&lt;/h3&gt;

&lt;p&gt;There are 2 main steps in RSA:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Generating keys&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using them for encryption and decryption&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;h3&gt;
  
  
  1. Generating Keys
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step a:&lt;/strong&gt; Select 2 prime numbers (p, q)&lt;br&gt;&lt;br&gt;
Let &lt;code&gt;p = 7&lt;/code&gt; and &lt;code&gt;q = 19&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step b:&lt;/strong&gt; Calculate their product&lt;br&gt;&lt;br&gt;
Let this be &lt;code&gt;N&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N = p * q
N = 7 * 19 = 133
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step c:&lt;/strong&gt; Calculate the Totient (T), also called Euler’s Totient Function.&lt;/p&gt;

&lt;p&gt;Euler’s Totient function tells us how many numbers less than &lt;em&gt;N&lt;/em&gt; share no common factors with &lt;em&gt;N&lt;/em&gt;.&lt;br&gt;&lt;br&gt;
For RSA, since &lt;em&gt;p&lt;/em&gt; and &lt;em&gt;q&lt;/em&gt; are prime, φ(N) = (p − 1)(q − 1).&lt;/p&gt;

&lt;p&gt;This counts how many numbers less than N are &lt;em&gt;coprime&lt;/em&gt; (relatively prime) with N — meaning their GCD is 1.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
Let N be 13.&lt;/p&gt;

&lt;p&gt;How many numbers less than 13 will produce a GCD of 1 with 13.&lt;br&gt;
Answer is 12&lt;/p&gt;

&lt;p&gt;For RSA, you can simply compute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;T = (p - 1) * (q - 1)
T = (7 - 1) * (19 - 1)
T = 6 * 18 = 108
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step d:&lt;/strong&gt; Choose a Public Key (E)&lt;/p&gt;

&lt;p&gt;This value must satisfy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;E must be &lt;strong&gt;coprime&lt;/strong&gt; with T (i.e., gcd(E, T) = 1)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;E must be &lt;strong&gt;less than T&lt;/strong&gt;&lt;br&gt;
Let &lt;code&gt;E = 29&lt;/code&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;29 is less than 108&lt;/li&gt;
&lt;li&gt;gcd(29, 108) = 1
So:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;E = 29
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step e:&lt;/strong&gt; Find the Private Key (D)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;D&lt;/code&gt; must satisfy the condition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(D * E) mod T = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means D is the &lt;em&gt;modular multiplicative inverse&lt;/em&gt; of E modulo T.&lt;/p&gt;

&lt;p&gt;Let D be 41&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(41 * 29) mod 108 = 1

(41 * 29) = 1189

1189 % 108 = 11 remainder 1

108 * 11 = 1188

1189 - 1188 = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;D = 41
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Encryption and Decryption
&lt;/h3&gt;

&lt;p&gt;Now that we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N = 133
E = 29
D = 41
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can encrypt and decrypt messages (which are represented as numbers).&lt;/p&gt;

&lt;h4&gt;
  
  
  Encryption (using Public Key)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cipher = Message ^ E mod N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Message = 60
Cipher  = 60^29 mod 133 = 72
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Decryption (using Private Key)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Message = Cipher ^ D mod N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Message = 72^41 mod 133 = 60 (the original)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we got back our message — RSA works!&lt;/p&gt;




&lt;h3&gt;
  
  
  Note
&lt;/h3&gt;

&lt;p&gt;RSA only works with numbers.&lt;br&gt;&lt;br&gt;
So if you have a message like &lt;code&gt;"Hello, World!"&lt;/code&gt;, it’s first converted to numbers using ASCII or UTF-8 before applying RSA.&lt;br&gt;&lt;br&gt;
After decryption, the number is converted back to text.&lt;/p&gt;


&lt;h3&gt;
  
  
  How Secure Is RSA?
&lt;/h3&gt;

&lt;p&gt;RSA’s security relies on the &lt;strong&gt;difficulty of factoring semi-prime numbers.&lt;/strong&gt;&lt;br&gt;
RSA security depends on how hard it is to factor &lt;strong&gt;n = p × q&lt;/strong&gt;, the larger &lt;strong&gt;n&lt;/strong&gt; (in bits), the harder the math problem.&lt;/p&gt;

&lt;p&gt;If you’re given &lt;code&gt;133&lt;/code&gt;, could you easily find &lt;code&gt;7&lt;/code&gt; and &lt;code&gt;19&lt;/code&gt;? Sure.&lt;br&gt;&lt;br&gt;
But what about a 2048-bit number — something with hundreds of digits?&lt;br&gt;&lt;br&gt;
That’s practically impossible with current computers.&lt;/p&gt;

&lt;p&gt;A 2048-bit RSA key means the digit can be as large as (2^2048)-1&lt;br&gt;
Which is roughly a 617-digit decimal number&lt;/p&gt;
&lt;h5&gt;
  
  
  Here is a table of different key lengths and time it would take to crack them
&lt;/h5&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;RSA Key Size&lt;/th&gt;
&lt;th&gt;Approximate Decimal Digits&lt;/th&gt;
&lt;th&gt;Factoring Difficulty&lt;/th&gt;
&lt;th&gt;Approximate Time to Break (with modern computers)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;256-bit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~77 digits&lt;/td&gt;
&lt;td&gt;Very easy&lt;/td&gt;
&lt;td&gt;Few seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;512-bit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~155 digits&lt;/td&gt;
&lt;td&gt;Still easy&lt;/td&gt;
&lt;td&gt;Minutes to hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;768-bit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~232 digits&lt;/td&gt;
&lt;td&gt;Hard, but done in labs&lt;/td&gt;
&lt;td&gt;Months (if you use supercomputers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1024-bit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~309 digits&lt;/td&gt;
&lt;td&gt;Very hard&lt;/td&gt;
&lt;td&gt;Thousands of years&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2048-bit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~617 digits&lt;/td&gt;
&lt;td&gt;Practically impossible&lt;/td&gt;
&lt;td&gt;Longer than universe’s age&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;4096-bit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~1234 digits&lt;/td&gt;
&lt;td&gt;Even harder&lt;/td&gt;
&lt;td&gt;Astronomically impossible&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;p&gt;As you can see it gets harder every time the number gets larger. If you read my blog on &lt;a href="https://dev.to/rayjay/how-software-works-encryption-3fg6"&gt;how software works-encryption&lt;/a&gt; I talked about the goal of modern encryption was to make encryption computationally expensive - so expensive that its useless to even try.&lt;/p&gt;



&lt;p&gt;Summary&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Public Key  = (E, N)
Private Key = (D, N)

Encrypt:   Cipher = Message ^ E mod N
Decrypt:   Message = Cipher ^ D mod N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>algorithms</category>
      <category>security</category>
      <category>cryptography</category>
      <category>mathematics</category>
    </item>
    <item>
      <title>How Software Works: Encryption</title>
      <dc:creator>Ray Jones Muiruri</dc:creator>
      <pubDate>Wed, 04 Jun 2025 13:09:09 +0000</pubDate>
      <link>https://forem.com/rayjonesmuiruri/how-software-works-encryption-3fg6</link>
      <guid>https://forem.com/rayjonesmuiruri/how-software-works-encryption-3fg6</guid>
      <description>&lt;h2&gt;
  
  
  How Software Works: Chapter 1
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Encryption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Welcome to the first chapter of &lt;em&gt;How Software Works&lt;/em&gt;—a series where we explore the inner workings of the technology that powers our digital lives. We’re kicking things off with a foundational concept in digital security: &lt;strong&gt;encryption&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is Encryption?
&lt;/h3&gt;

&lt;p&gt;We rely on software to protect our data every day, but the average person rarely stops to ask: &lt;em&gt;How does this protection actually work?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ever wondered how your phone password prevents unauthorized access? Or what stops attackers from logging into your Facebook, Google, or X account? The answer begins with computer security—and at the heart of that is &lt;strong&gt;encryption&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  A Brief Look at Computer Security
&lt;/h3&gt;

&lt;p&gt;Let’s start with a basic definition:&lt;br&gt;
&lt;strong&gt;Computer security&lt;/strong&gt; is the science of protecting digital data.&lt;/p&gt;

&lt;p&gt;In many ways, computer security is technology’s solution to a problem created by technology itself.&lt;/p&gt;

&lt;p&gt;Not long ago, people stored sensitive data in filing cabinets or shoeboxes under their beds. To steal that data, someone had to break into your home or office. Today, your bank details, private messages, and personal photos travel the world through the internet—and someone can steal them from the other side of the planet without you knowing.&lt;/p&gt;

&lt;p&gt;In fact, you may only realize it happened when your bank calls to ask why you just spent KSH 300,000 on digital gift cards in another country.&lt;/p&gt;

&lt;p&gt;This is where encryption comes in—why it’s important, and what it tries to solve.&lt;/p&gt;




&lt;h3&gt;
  
  
  What Encryption Does
&lt;/h3&gt;

&lt;p&gt;Encryption lets us lock our data so that only &lt;strong&gt;we&lt;/strong&gt; (or those we authorize) can unlock it. It’s not the only tool used in computer security, but it’s the most essential one.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Goal of Encryption
&lt;/h4&gt;

&lt;p&gt;Imagine a file on your device. It could be text, a photo, a spreadsheet, or a video. You want to keep it private—but also be able to access it easily.&lt;/p&gt;

&lt;p&gt;Encryption allows you to convert that file into a new, scrambled format that appears meaningless to anyone without permission. This scrambled version is called &lt;strong&gt;ciphertext&lt;/strong&gt;. When you want to read or view the original file again, you &lt;strong&gt;decrypt&lt;/strong&gt; the ciphertext back into its original form—called &lt;strong&gt;plaintext&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Plaintext&lt;/strong&gt;: The original readable data (even if it’s not text—could be an image, video, etc.)&lt;br&gt;
&lt;strong&gt;Ciphertext&lt;/strong&gt;: The unreadable, encrypted version of that data&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Why Encryption Matters
&lt;/h3&gt;

&lt;p&gt;Attackers—malicious hackers, criminals, or snoopers—try to decrypt ciphertext without having the proper key. Good encryption is designed to make this practically impossible.&lt;/p&gt;

&lt;p&gt;Of course, just like no physical lock is truly unbreakable, no encryption scheme is &lt;em&gt;theoretically&lt;/em&gt; unbreakable either. Given unlimited time and computational power, any encrypted data can eventually be cracked.&lt;/p&gt;

&lt;p&gt;But modern encryption aims to make cracking so expensive—so computationally demanding—that it's useless to even try.&lt;/p&gt;

&lt;p&gt;This is the key idea behind secure systems: &lt;strong&gt;make attacks infeasible&lt;/strong&gt; rather than impossible.&lt;/p&gt;

&lt;p&gt;Before we get into how encryption works in the digital age, let’s look at where it all began—before computers, when secrets were passed in whispers, codebooks, and handwritten messages.&lt;/p&gt;




&lt;h2&gt;
  
  
  Historical Roots: Ciphers and Spies
&lt;/h2&gt;

&lt;p&gt;Even centuries before the internet, people had secrets worth protecting. Early forms of encryption were used by generals, kings, and spies. These simple methods laid the groundwork for today’s digital encryption.&lt;/p&gt;




&lt;h3&gt;
  
  
  Transposition: Same Data, Different Order
&lt;/h3&gt;

&lt;p&gt;One of the simplest historical techniques is called &lt;strong&gt;transposition&lt;/strong&gt;. It’s exactly what it sounds like—rearranging the letters or elements of a message into a new order.&lt;/p&gt;

&lt;p&gt;For example, the message “MEET AT DAWN” could be scrambled as “TAM WNE EED” using a transposition scheme. The letters are all still there—but out of order.&lt;/p&gt;

&lt;p&gt;Early transposition ciphers often relied on grids, patterns, or other agreed-upon structures. The trick was knowing the pattern to reverse the scrambling and reconstruct the original message.&lt;/p&gt;

&lt;p&gt;However, once someone figures out the pattern, the encryption breaks. This leads us to a critical rule in modern cryptography.&lt;/p&gt;




&lt;h3&gt;
  
  
  Kerckhoffs’s Principle
&lt;/h3&gt;

&lt;p&gt;In the 19th century, Dutch cryptographer Auguste Kerckhoffs proposed a key principle for any good encryption system:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The security of a system should depend only on the secrecy of the key—not the secrecy of the method.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is still true today. Modern encryption algorithms (like AES or RSA) are publicly known and published. Anyone can study or use them—but without the &lt;strong&gt;key&lt;/strong&gt;, they’re useless for decrypting data.&lt;/p&gt;

&lt;p&gt;This naturally leads to the concept of...&lt;/p&gt;




&lt;h3&gt;
  
  
  Cipher Keys
&lt;/h3&gt;

&lt;p&gt;If the encryption method itself isn’t secret, how is your data protected?&lt;/p&gt;

&lt;p&gt;The answer is the &lt;strong&gt;cipher key&lt;/strong&gt;. A cipher key is a secret, randomly generated value used during the encryption and decryption process. It ensures that even though everyone knows how the algorithm works, only those with the correct key can unlock the data.&lt;/p&gt;

&lt;p&gt;So, while the algorithm might be standard, the key is unique to your data and must be kept secret.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;In the next chapter of &lt;em&gt;How Software Works&lt;/em&gt;, we’ll dive into &lt;strong&gt;symmetric and asymmetric encryption&lt;/strong&gt;—two fundamental approaches to securing communication. We’ll explore how your web browser uses encryption when you visit a website, and what’s really happening when you see that little padlock icon in the address bar.&lt;/p&gt;




&lt;p&gt;Thanks for reading Chapter 1!&lt;br&gt;
Feel free to share your thoughts, questions, or ideas you'd like me to cover next.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>🔌 Using Plugins in Go: A Simple Introduction</title>
      <dc:creator>Ray Jones Muiruri</dc:creator>
      <pubDate>Thu, 08 May 2025 11:57:15 +0000</pubDate>
      <link>https://forem.com/rayjonesmuiruri/using-plugins-in-go-a-simple-introduction-4llc</link>
      <guid>https://forem.com/rayjonesmuiruri/using-plugins-in-go-a-simple-introduction-4llc</guid>
      <description>&lt;h2&gt;
  
  
  🔧 What Are Go Plugins?
&lt;/h2&gt;

&lt;p&gt;A plugin in Go is a &lt;code&gt;.so&lt;/code&gt; (shared object) file built from a Go package. It can be loaded at runtime using Go’s plugin package, allowing you to call its functions and access its variables dynamically.&lt;/p&gt;

&lt;h4&gt;
  
  
  Plugins are supported on Linux and macOS (not Windows).
&lt;/h4&gt;

&lt;p&gt;Create a directory with this similar structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go-plugin-tutorial/
├── main.go         &lt;span class="c"&gt;# the main program that loads the plugin&lt;/span&gt;
├── plugin/
│   └── greet.go    &lt;span class="c"&gt;# Plugin code&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✏️ Step 1: Create the Plugin
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main
import "fmt"
// the variables or functions must be exported
func Greet(name string) {
    fmt.Printf("Hello %s\n",name)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Important: the plugin must use package main and exported symbols (capitalized).
&lt;/h4&gt;

&lt;h3&gt;
  
  
  🛠️ Step 2: Build the Plugin
&lt;/h3&gt;

&lt;p&gt;From the root directory, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go build -buildmode=plugin -o greet.so plugin/greet.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This generates greet.so, a shared object file you can load at runtime.&lt;/p&gt;

&lt;h3&gt;
  
  
  💡 Step 3: Load the Plugin in Your App
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "plugin"
    "log"
)

func main() {
    // Load plugin
    plug, err := plugin.Open("plugin/greet.so")
    if err != nil {
        log.Fatal(err)
    }
    // Lookup exported symbol
    symGreet, err := plug.Lookup("Greet")
    if err != nil {
        log.Fatal(err)
    }
    // Assert that it's a function with the right signature
    greetFunc, ok := symGreet.(func(string))
    if !ok {
        log.Fatal("unexpected type from module symbol")
    }
    // Call it!
    greetFunc("Go Developer")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ▶️ Step 4: Run It
&lt;/h3&gt;

&lt;p&gt;Make sure greet.so is in the same directory as main.go or provide accurate path and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello Go Developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






</description>
    </item>
    <item>
      <title>Hello World</title>
      <dc:creator>Ray Jones Muiruri</dc:creator>
      <pubDate>Fri, 11 Apr 2025 22:41:11 +0000</pubDate>
      <link>https://forem.com/rayjonesmuiruri/hello-world-13cf</link>
      <guid>https://forem.com/rayjonesmuiruri/hello-world-13cf</guid>
      <description>&lt;p&gt;Hello, World!&lt;/p&gt;

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