<?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"><channel><title><![CDATA[Simon Sickle’s DevLog]]></title><description><![CDATA[I’m a senior Android software engineer, currently working at Square. In my free time I like to play around with home automation. When not behind a computer, I’m outdoors with my family and camera!]]></description><link>https://blog.simonsickle.com</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 08:26:33 GMT</lastBuildDate><atom:link href="https://blog.simonsickle.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[1Password Meets Git]]></title><description><![CDATA[👋 Hey there! I'm Simon, a senior Android engineer at Block. I have been hacking around on Android roughly since its creation: from kernel mods to app creation, I have done a little bit of it all. I also dabble in other projects, like home automation...]]></description><link>https://blog.simonsickle.com/1password-meets-git</link><guid isPermaLink="true">https://blog.simonsickle.com/1password-meets-git</guid><category><![CDATA[Security]]></category><category><![CDATA[ssh]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Simon Sickle]]></dc:creator><pubDate>Thu, 15 Sep 2022 23:38:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/mT7lXZPjk7U/upload/v1663279666978/LBdEc1g43.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>👋 Hey there! I'm Simon, a senior Android engineer at <a target="_blank" href="https://block.xyz">Block</a>. I have been hacking around on Android roughly since its creation: from kernel mods to app creation, I have done a little bit of it all. I also dabble in other projects, like home automation and helpful utilities to make my life a little bit easier.</em></p>
<h2 id="heading-security-and-you">Security and you</h2>
<p>With the ever evolving complexity of the internet, you may not even realize the amount of attack surface available to a bad actor. We all know the best practices now that have been hammered into our heads: use a random password different for every website, use two-factor auth, use a password manager to encrypt your digital life, etc. Most engineers will abide by these well established rules, but how many take it a step further and apply it to the software we create? This is where <a target="_blank" href="https://1password.com/">1Password 8</a> comes in.</p>
<h3 id="heading-key-to-the-kingdom">Key to the kingdom</h3>
<p>Without going too far in depth, SSH keys can be thought of the same way as your home's front door key - you use something you have to prove that access should be granted. For years this has been a standard and secure practice to access hosts over the internet by generating and storing a key on your local disk. What happens if your laptop takes a bath or you decide that shiny M1 processor is worth an upgrade, though - you now need to go through a long process of restoring your backup (you have one, right?) or creating a new key and adding it to all of your services... This is <em>not fun</em>.</p>
<p>What if I told you there is an easier way, using a tool that should already be in your back pocket?</p>
<h3 id="heading-1password-saves-the-day-key">1Password saves the day (key)</h3>
<p>1Password has a wonderful SSH key generation functionality built into the mobile and desktop versions. Simply hit "New Item" and pick "SSH Key". </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663280502282/GHG1CzO8I.png" alt="Screen Shot 2022-09-15 at 6.21.19 PM.png" /></p>
<p>Give it a good name, hit "add private key" and click "generate". By default <a target="_blank" href="https://developer.1password.com/docs/ssh/manage-keys/#ed25519">Ed25519</a> is used to generate the key but you may select RSA instead if you need that compatibility. <em>Most</em> servers now days should work fine with Ed25519, the most modern and fastest standard, however.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663280700174/KSvIoT-_B.png" alt="Screen Shot 2022-09-15 at 6.24.47 PM.png" /></p>
<p>Save your new key to your private vault and you are ready to go (well, almost... stick with me). Now you will click on the row in 1Password that says "public key" and copy it to your clipboard. Go <a target="_blank" href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-account">add that to GitHub</a> now.</p>
<h3 id="heading-ok-but-how-do-i-use-it">Ok, but how do I use it</h3>
<p>Ok you caught me, you have a fancy new key store but no way to actually use it to SSH into your servers or to clone a repository. Worry not, 1Password thought of this and provides a SshAgent to do our bidding (err, our authenticating at least). </p>
<p>To enable this functionality, we need to tell 1Password that we are a developer which also enables fancy CLI options! Hit <code>CMD + ,</code> or open the app settings in the way your OS supports and click "developer". Enable the SSH Agent and optionally biometrics if you wish.  Now, we must add a snippet of code to our SSH configuration file to tell the SSH command we wish to delegate key management to 1Password. You can follow the directions and copy the snippet like in the screen below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663281159509/5BXDDrfPV.png" alt="Screen Shot 2022-09-15 at 6.32.28 PM.png" /></p>
<p>Once you have done this successfully,  you will see a screen that looks like this telling you how awesome you are.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663281107611/8P5Bal3eV.png" alt="Screen Shot 2022-09-15 at 6.31.20 PM.png" /></p>
<h4 id="heading-note-what-if-i-only-want-to-use-it-for-git-and-not-my-servers">Note: what if I only want to use it for git and not my servers?</h4>
<p>No worries then, I have you covered! At work, we have some complex configurations and security rules that wouldn't allow me to store my SSH key in this manor... I do, however, work on some open source software from time to time which requires that I have an SSH key to authenticate with GitHub. To accomplish this, I modified the pasted snippet from 1Password to only use the SSH agent for github connections using the git user. Run the following command (on macOS - for Linux and Windows you need to change the SSH Agent location)</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">'Host github.com
    User git
    Hostname github.com
    IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"'</span> &gt;&gt; ~/.ssh/config
</code></pre>
<p>And to confirm that everything is working, you can run the following command to see if 1Password prompts you for authentication and if GitHub recognizes your key!</p>
<pre><code class="lang-bash">ssh git@github.com
</code></pre>
<h3 id="heading-what-about-signing-my-code">What about signing my code?</h3>
<p>Luckily, GitHub now supports code signed by an SSH key! This means you can use 1Password's SSH agent functionality to sign your commits instead of relying on GPG (which has been troublesome in the past on macOS).</p>
<p>To configure this, make sure that you have updated to the latest version of 1Password 8 for your OS and then you should see a "configure for commit signing" pop-up at the top of your key which can auto-configure git to use 1Password for signing. You can learn more about this feature from <a target="_blank" href="https://developer.1password.com/docs/ssh/git-commit-signing/">1Password's support site</a>. Be sure to add your SSH key to as a "signing" type key this time (it may be the same as your auth key, but you need to add it in both auth and signing locations).</p>
<p>Last thing to do is to sit back and enjoy your now biometrics secured workflow</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663284393270/KgPNMpQWy.png" alt="Screen Shot 2022-09-15 at 7.25.38 PM.png" /></p>
<h2 id="heading-summary">Summary</h2>
<p>Security is important and everyone must play a part in a secure ecosystem. Humans are the weakest link in the chain and are <a target="_blank" href="https://www.theverge.com/2020/7/15/21326656/twitter-hack-explanation-bitcoin-accounts-employee-tools">often the target by malicious actors</a>. By migrating to your SSH keys (the very tool used to identify yourself and provide access) to 1Password, you are insuring a smaller attack surface and saving yourself from having to type a (likely weak) password every time you need to sign a git commit or connect over SSH by using biometrics, a security-key (like a YubiKey), or your secure vault password that won't be shared on any other sites. Don't just take my word for it though, go inspect <a target="_blank" href="https://support.1password.com/1password-security/">their security model</a> yourself to decide what is right for you. </p>
]]></content:encoded></item><item><title><![CDATA[Drawing QR Codes in Jetpack Compose]]></title><description><![CDATA[👋 Hey there! I'm Simon, a senior Android engineer at Block. I have been hacking around on Android roughly since its creation: from kernel mods to app creation, I have done a little bit of it all. I also dabble in other projects, like home automation...]]></description><link>https://blog.simonsickle.com/drawing-qr-codes-in-jetpack-compose</link><guid isPermaLink="true">https://blog.simonsickle.com/drawing-qr-codes-in-jetpack-compose</guid><category><![CDATA[Jetpack Compose]]></category><category><![CDATA[android app development]]></category><category><![CDATA[Android]]></category><category><![CDATA[canvas]]></category><category><![CDATA[qr code]]></category><dc:creator><![CDATA[Simon Sickle]]></dc:creator><pubDate>Wed, 14 Sep 2022 01:48:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/yUVSOjr5ZkQ/upload/v1663107075800/SfOx8W2vt.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>👋 Hey there! I'm Simon, a senior Android engineer at <a target="_blank" href="https://block.xyz">Block</a>. I have been hacking around on Android roughly since its creation: from kernel mods to app creation, I have done a little bit of it all. I also dabble in other projects, like home automation and helpful utilities to make my life a little bit easier.</em></p>
<p><em>If you have questions or comments, you can reach me on <a target="_blank" href="https://twitter.com/ssickle42">Twitter</a>!</em></p>
<h2 id="heading-i-want-my-qr-code-and-i-want-it-now">I want my QR code and I want it <em>now</em></h2>
<blockquote>
<p>"Once a new technology rolls over you, if you’re not part of the steamroller, you’re part of the road"</p>
<p>— <cite>Stewart Brand</cite></p>
</blockquote>
<p>For a recent project, I needed to show a QR code to allow a user to scan and retrieve data from another device. While there are <em>tons</em> of examples of how to do exactly this in Android, there are not many examples of how to do this within Jetpack Compose. As any engineer would do, I decided to write out the pros and cons of 3 approaches I had considered:</p>
<ol>
<li>Using a static asset inside of my application <strong>(Easy)</strong></li>
<li>Using an API to request a QR code image <strong>(Moderate)</strong></li>
<li>Generate the QR code on device and draw it with <strong>(Hard)</strong></li>
</ol>
<h4 id="heading-static-asset">Static Asset</h4>
<p>Using a static asset seems like the easiest solution here and is certainly worth a mention. Why write a ton of code when you can just drop an SVG into your app's resources and display it like you would any other image? The drawbacks here are that you will be increasing your application size and preventing the flexibility of updating this code's contents on the fly. </p>
<h4 id="heading-api-network-call">API / Network Call</h4>
<p>Using a network call is certainly another option here: we already have an endpoint that can generate and then return a PNG of a QR code to my specification. The upside is flexibility in changes to the design of this code and it's contents, but at the expense of needing to make a network call and for the device to be online.</p>
<h4 id="heading-generation">Generation</h4>
<p>This option <em>almost</em> scared me away as I have <em>never</em> worked with the Android Canvas APIs before but had heard horrors from fellow engineers about the quirks and pain of working with the Canvas. This all changes with Jetpack Compose, however! Google took the time to make improvements to these Canvas APIs - even further, anything that supports Skia could use the same code to draw with. This is a huge win for Compose Multiplatform, which allows writing the same UI code to run across multiple targets. This generation would be much more performant than a network call, keep the APK size down, and would be "future proof" if I needed to update the contents of the QR code. <em>This is my winner.</em></p>
<h2 id="heading-hand-me-my-paintbrush">Hand me my paintbrush</h2>
<p>At a glance, I am going to need to do the following:</p>
<ol>
<li>Create a project in Android Studio with support for Jetpack Compose</li>
<li>Create an activity to show my QR code right in the middle</li>
<li>Create a Composable function that hosts a <code>Canvas</code> Composable</li>
<li>Use the <code>DrawScope</code> to draw the QR code data onto the canvas</li>
</ol>
<h3 id="heading-drawing-a-qr-code">Drawing a QR code</h3>
<p>As you may have noticed, step 4 is pretty vague... How does one draw a QR code? What even makes these magical bits of color work? Let's dive in so we can determine how one should be drawn.</p>
<h4 id="heading-the-finders">The finders</h4>
<p>If you don't know what the thing you are searching for looks like, how will you find it? When the computer processes the frames of data coming from your phone's camera to look for a QR code, it is looking for a distinct spacing of 3 squares. These 3 squares are known as the finder pattern. Most QR scanners also require a bit of a quiet zone around these finder patterns where there is <em>nothing</em> else - around 16 pixels usually works fine.</p>
<h4 id="heading-the-data-bits">The data bits</h4>
<p>Now that you have found what you are looking for, you can figure out what it means to you. In this case, the computer will read the data in form of columns and rows and then use an algorithm to decode the meaning of these little bits of data. This data, luckily, does not need to be perfect as a certain level of data correction is built in (and is configurable in most QR encoders).</p>
<h3 id="heading-generation-of-a-barcode">Generation of a barcode</h3>
<p>To generate the instructions we need to be able to draw a QR code on the canvas, we are going to need to use a library called ZXing - the tried and true java library for making barcodes of many different types. You may add it to your project by adding the following dependency.</p>
<pre><code class="lang-kotlin">implementation(<span class="hljs-string">"com.google.zxing:core:3.5.0"</span>)
</code></pre>
<p>Now to generate a QR code in a format we can use, you need to call the ZXing Encoder with the information you wish to define the code (see <code>QrCode.createQrCode</code> in sample). Next we draw the finder patterns - you can see  <code>QrCode.kt</code> and <code>QrCodeFinderDrawing.kt</code> for examples of how to do this; the overview is that you want to determine the position of each of these markers by using a size ratio of the generated matrix's width and height.</p>
<p>Finally, you will need to draw the data into the canvas. To do this, you will need to look through the ByteMatrix and check to see if a bit is enabled or disabled at that location. If it is, draw a simple rectangle on the canvas at the appropriate offset with a size matching the row and column. (see <code>QrCodeDataDrawing.kt</code>)</p>
<h3 id="heading-lessons-learned">Lessons learned</h3>
<p>This project was by no means easy, but I learned a lot along the way. Drawing may seem intimidating at first, but just remember that you are essentially telling the computer to do what you already know how to do - move a pen/painter across a canvas. If something doesn't work, break down the parts into small consumable pieces which can be easily achieved.</p>
<h3 id="heading-view-my-code">View My Code</h3>
<p>You can take a look at my demo app, embedded below, and copy any code as you please! See something that could be improved upon? Feel free to submit a PR as well</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/simonsickle/ComposableBarcode/tree/main">https://github.com/simonsickle/ComposableBarcode/tree/main</a></div>
]]></content:encoded></item></channel></rss>