<?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 Jacob Vynnyk on Medium]]></title>
        <description><![CDATA[Stories by Jacob Vynnyk on Medium]]></description>
        <link>https://medium.com/@jacobvynnyk?source=rss-c0c317163070------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3hwj2JOkLF48ekE2oqY8oQ.jpeg</url>
            <title>Stories by Jacob Vynnyk on Medium</title>
            <link>https://medium.com/@jacobvynnyk?source=rss-c0c317163070------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:47:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jacobvynnyk/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[Simple Encryption in Android App]]></title>
            <link>https://jacobvynnyk.medium.com/simple-encryption-in-android-app-74a85e572b1b?source=rss-c0c317163070------2</link>
            <guid isPermaLink="false">https://medium.com/p/74a85e572b1b</guid>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[decryption]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Jacob Vynnyk]]></dc:creator>
            <pubDate>Sat, 09 May 2020 23:18:00 GMT</pubDate>
            <atom:updated>2021-02-04T15:57:49.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K2RdpkBv-urTePcX" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Every Android developer sooner or later faced with situation when he needs to keep save sensitive information inside an app. You may think right now :</p><blockquote>— uhh!! Seems we are going to code a lot!</blockquote><p>and you will be almost right :) as in comparison with our iOS colleagues that simply use the <a href="https://developer.apple.com/library/mac/documentation/Security/Conceptual/keychainServConcepts/01introduction/introduction.html">KeyChain service</a>, which is a part of Apple’s overall <a href="https://www.apple.com/business/docs/iOS_Security_Guide.pdf">security framework for iOS</a>. Ah, as always!</p><p>And what should we do with data on Android? Yes, store it in SharedPreferences, but after it’s been encrypted.</p><p>Lets take a look to <strong><em>javax.crypto</em></strong> package and find out what we need to encrypt information:</p><ul><li>Generate <strong><em>SecretKey</em></strong></li><li>Retrieve it from <strong><em>KeyStore</em></strong></li><li>Obtain instance of <strong><em>Cipher</em></strong></li><li>Initialize <em>Cipher</em><strong><em> </em></strong>with corresponds <em>encryption mode</em> and <em>SecretKey</em></li><li>Encrypt or decrypt data</li><li>Fight with wish to hard code something during cipher initialization.</li></ul><p>Let’s start coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QQ1-n-uhl4-TKtXw" /><figcaption>Photo by <a href="https://unsplash.com/@sergeytrofimov?utm_source=medium&amp;utm_medium=referral">Serghei Trofimov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ol><li><strong>Generate <em>SecretKey</em></strong></li></ol><p>To generate <em>SecretKey</em> you will need to generate some <em>alias </em>that will bound to secret key in <em>KeyStore</em>. Using this alias you will be able to retrieve it from <em>KeyStore</em>. Usually this alias bound to user, it is very helpful if you application support multi accounts login.</p><pre>const val <em>KEYSTORE_PROVIDER_ANDROID </em>= &quot;AndroidKeyStore&quot;</pre><pre>private fun generateSecretKey(alias: String): SecretKey {<br>    try {<br>        val builder =<br>                KeyGenParameterSpec.Builder(alias,<br>                        KeyProperties.<em>PURPOSE_ENCRYPT </em>or  <br>                        KeyProperties.<em>PURPOSE_DECRYPT</em>)<br>       .setBlockModes(KeyProperties.<em>BLOCK_MODE_GCM</em>)<br>       .setEncryptionPaddings(KeyProperties.<em>ENCRYPTION_PADDING_NONE</em>)<br><br>       val keyGenerator = KeyGenerator.getInstance(<br>                KeyProperties.<em>KEY_ALGORITHM_AES</em>,<br>                <em>KEYSTORE_PROVIDER_ANDROID</em>)<br><br>        keyGenerator?.init(builder.build())<br>        return keyGenerator?.generateKey()<br>    } catch (e: Exception) {<br>        Timber.d(&quot;Failed to create key&quot;)<br>        throw e<br>    }<br>}</pre><p><strong>2. Retrieve it from <em>KeyStore</em></strong></p><p>Retrieve <em>SecretKey</em> from <em>KeyStore</em> using <em>alias</em> from the previous step.</p><pre>val keyStore = KeyStore.getInstance(<em>KEYSTORE_PROVIDER_ANDROID</em>)<br>keyStore.load(null)</pre><pre>private fun retrieveSecretKey(): SecretKey? {<br>    val entry = keyStore.getEntry(privateKeyId, null)<br>    val secretKey<em>: </em>SecretKey? = (entry as? <br>                               (KeyStore.SecretKeyEntry))?.<em>secretKey</em></pre><pre>    return secretKey<br>}</pre><p><strong>3. Obtain instance of <em>Cipher</em></strong></p><pre>val AES_TRANSFORMATION = &quot;AES/GCM/NoPadding&quot;<br>val cipher = Cipher.getInstance(AES_TRANSFORMATION)</pre><p><strong>4. Initialize <em>Cipher</em> it with correspond encryption mode and <em>SecretKey</em></strong></p><p>To initialize <em>Cipher we will need </em><a href="https://en.wikipedia.org/wiki/Initialization_vector"><em>Initialization Vector</em></a><em> (IV). </em>Initialization Vector is is a fixed-size input to a cryptographic primitive. It is typically required to be random or pseudorandom. The point of an <em>IV</em> is to tolerate the use of the same key to encrypt several distinct messages.</p><p>To put it simply, it’s a cryptographic feature that injects randomness to make it more secure.</p><pre>val secureRandom = SecureRandom()<br>val initVector = ByteArray(128)<br>secureRandom.nextBytes(initVector)</pre><p>The important part is that the IV you use in the encryption must be the same one you use in the decryption. So it should be stored like this.</p><pre>val encodedInitVector =<br>       Base64.encodeToString(initVector, Base64.<em>DEFAULT</em>)</pre><pre>sharedPreferences.edit()<br>                 .putString(ENCRYPTION_IV_KEY, encodedInitVector)<br>                 .apply()</pre><p>Now we are ready to init <em>Cipher</em> for <em>encryption</em></p><pre>val gcmSpec = GCMParameterSpec(128, initVector)<br>cipher?.init(Cipher.<em>ENCRYPT_MODE</em>, getSecretKey(), gcmSpec)</pre><p>And here we create <em>Cipher</em> for <strong><em>decryption</em></strong></p><pre>private fun getInitVectorKey(): ByteArray? {<br>    val encodedIv = preferenceManager<br>                         .getString(ENCRYPTION_IV_KEY, null)<br>    return Base64.decode(encodedIv, Base64.<em>DEFAULT</em>)<br>}</pre><pre>val cipher = Cipher.getInstance(AES_TRANSFORMATION)<br><br>val spec = GCMParameterSpec(AUTH_TAG_LENGTH, getInitVectorKey())<br>cipher?.init(Cipher.<em>DECRYPT_MODE</em>, retrieveSecretKey(), spec)</pre><p><strong>5. Encrypt or decrypt data</strong></p><p>After <em>Cipher</em> has been created and initialized, we are able to encrypt or decrypt data</p><pre>@Throws(Exception::class)<br>fun encrypt(message: ByteArray): ByteArray? {<br>    return encryptCipher.doFinal(message)<br>}</pre><pre>@Throws(Exception::class)<br>fun decrypt(encryptionKey: ByteArray?): ByteArray? {<br>    return decryptCipher.doFinal(encryptionKey)<br>}</pre><p><strong>6. Fight with wish to hard code something during cipher initialization.</strong></p><p>During setting <em>Cipher</em> you might be tempted to hard code <em>Initialization Vector</em> or store it from initialized <em>Cipher</em> with method that does not need <em>GCMParameterSpec </em>with<em> IV</em></p><pre>val cipher = Cipher.getInstance(AES_TRANSFORMATION)<br>cipher.init(Cipher.<em>ENCRYPT_MODE</em>, getSecretKey())<br>val initVector = cipher.<em>iv<br>storeInitVector(initVector)</em></pre><p><a href="https://doridori.github.io/Android-Security-Beware-of-the-default-IV/#sthash.jymTOnIq.mCSYcOEz.dpbs">Don’t do it</a>.</p><p>After data is encrypted it is ready to be stored in <em>SharedPreferences</em> as follows</p><pre>val encryptedBytes = aesCipher.encrypt(message.<em>toByteArray</em>())<br>val encodedMsg = Base64.encodeToString(<br>                               encryptedBytes, Base64.<em>DEFAULT</em>)<br>sharedPreferences.edit()<br>                 .putString(YOUR_DATA_KEY, encodedMsg)<br>                 .apply()</pre><p>Or retrieved from <em>SharedPreferences</em></p><pre>val encodedMsg = sharedPreferences.getString(YOUR_DATA_KEY, null)<br>val encryptedMsg = Base64.decode(encodedMsg, Base64.<em>DEFAULT</em>)<br>val messageBytes = aesCipher.decrypt(encryptedMsg)<br>val message = String(messageBytes, Charsets.UTF_8)</pre><p><strong>Integration</strong></p><p>This code sample intended to work on Android 6 and newer, so please check you <em>build.gradle </em>file</p><pre>android <strong>{</strong><br>    defaultConfig <strong>{</strong><br>        minSdkVersion 23<br>    }<br>}</pre><p>All this code may obsolete very soon as new Encrypted Shared Preference API from the AndroidX artifacts will be released, so that it will be available right from the box!</p><h4>Enjoy coding!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74a85e572b1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to open AR Portal in 5 min with Java & Viro Core]]></title>
            <link>https://medium.com/ar-vr-journey/how-to-open-ar-portal-in-5-min-with-java-viro-core-27a5d498f8b?source=rss-c0c317163070------2</link>
            <guid isPermaLink="false">https://medium.com/p/27a5d498f8b</guid>
            <category><![CDATA[voir]]></category>
            <category><![CDATA[virtual-reality]]></category>
            <category><![CDATA[ar]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <dc:creator><![CDATA[Jacob Vynnyk]]></dc:creator>
            <pubDate>Sun, 23 Jun 2019 21:58:54 GMT</pubDate>
            <atom:updated>2019-07-15T14:25:43.111Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*XzrlEJ45a4w1YeAQIFkPKw.png" /><figcaption>Future is near</figcaption></figure><p><strong>Portal — magical or technological doorways that connect two locations, dimensions, or points in time. So right now we gonna build such portal that will lead as to another place or speaking science fiction way — to another dimension.</strong></p><p><a href="https://drive.google.com/open?id=1VZ0bu6P810yvk43fLeXDLNeBVWyy6FCS">ardemo.mp4</a></p><p><strong><em>If you are a new Viro developer, use </em></strong><a href="https://virocore.viromedia.com/docs/getting-started"><strong>Getting Started</strong></a><strong><em> guide to get setup with Viro before continuing with this tutorial. Viro is free and easy to set up!</em></strong></p><h3>PREREQUISITES</h3><ol><li>OSX computer</li><li>Android Device from this <a href="https://developers.google.com/ar/discover/supported-devices">supported device list</a></li><li>Viro Core -&gt; <a href="https://virocore.viromedia.com/docs/getting-started">Getting Started </a>guide for setting up Viro</li><li>Assets you can find <a href="https://drive.google.com/open?id=1Zgq5zKmnG9L3TKOjg0qhbfz282WaG1Bj">here</a></li></ol><h3>Prepare Assets</h3><p>Download assets and put it in Android <strong><em>assets</em></strong> folder</p><h3>Trending AR VR Articles:</h3><blockquote><a href="https://arvrjourney.com/five-augmented-reality-usages-that-solve-real-life-problems-55e7a81f61b">1. Five Augmented Reality Uses That Solve Real-Life Problems</a></blockquote><blockquote><a href="https://arvrjourney.com/virtual-reality-headsets-what-are-the-options-which-is-right-for-you-9ea008c7e318">2. Virtual Reality Headsets: What are the Options? Which is Right For You?</a></blockquote><blockquote><a href="https://arvrjourney.com/how-xr-can-unleash-cognition-3bda13026ade">3. How XR Can Unleash Cognition</a></blockquote><blockquote><a href="https://arvrjourney.com/oculus-go-the-nintendo-switch-of-vr-6827e1b91055">4. Oculus Go, the Nintendo Switch of VR</a></blockquote><h3>Building AR portal</h3><p>First of all we need to load portal model</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bd01bfe39d47f533eea63b5071daa50/href">https://medium.com/media/6bd01bfe39d47f533eea63b5071daa50/href</a></iframe><p>Next step is build portal itself</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d470dd1fbd1e98d1aa2ec1ef19d83c2/href">https://medium.com/media/6d470dd1fbd1e98d1aa2ec1ef19d83c2/href</a></iframe><p>If you want to allow user to enter into the portal and looks around do not forget to set <strong><em>passable</em></strong> property to <strong><em>true</em></strong>, like it is done in line 6</p><p>Next step is setting up background for portal</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc73b383b19d65fe0ae173ab99f9fdfc/href">https://medium.com/media/fc73b383b19d65fe0ae173ab99f9fdfc/href</a></iframe><p>And finally the last step is to add portal scene to the root node of Viro view scene when it is become ready, so basically in <em>onSuccess() </em>method</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e37f0040fd37cc21e5fa8a6930880c/href">https://medium.com/media/25e37f0040fd37cc21e5fa8a6930880c/href</a></iframe><p>So what we see here? Let’s go step by step. When <a href="https://developer.viromedia.com/virocore/reference/com/viro/core/ViroView.html"><em>ViroView</em></a> will be ready it notifies us by calling method <strong><em>onSuccess(), </em></strong>it is the best time to create main scene and pass it to <em>ViroView</em>. Next we create simple <a href="https://developer.viromedia.com/virocore/reference/com/viro/core/OmniLight.html"><em>OmniLight</em></a> and add it to the scene, corresponds to <a href="https://developer.viromedia.com/virocore/reference/com/viro/core/package-summary.html">Viro API</a>, <em>OmniLight</em> is a light source that casts light in all directions from a given position, we need it in order to see all 3D objects that we add to the scene, make sure you add at list one <em>OmniLight </em>object to the scene, otherwise you won’t see any AR objects. And finally we set position for portal scene, so it will appear in 2 meters in front of you.</p><p>We are ready to go, build and launch the app!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qgqsNTmIHlCi83s7Y1CISw.jpeg" /><figcaption>Grand Canyon, Arizona, USA</figcaption></figure><p><strong>Provide user with more advanced experience</strong></p><p>Class <a href="https://developer.viromedia.com/virocore/reference/com/viro/core/PortalScene.html"><em>PortalScene</em></a> has listener that allows as to be notified when user enters or exits a portal, so in that way we can provide some additional affect such like play some specific to the place sound, so we just need to prepare sound and run it on user enters event and stop on exit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66b8e7bc2638c2ba28a444bf7447c627/href">https://medium.com/media/66b8e7bc2638c2ba28a444bf7447c627/href</a></iframe><p><strong>Viro</strong> is very simple and simultaneously powerful library, that allows us to diversify the world and build very interesting apps.</p><p>Useful links : <a href="https://virocore.viromedia.com/docs/overview">To read</a>, <a href="https://hdrihaven.com/">Free assets bank</a>, <a href="http://www.hdrlabs.com/sibl/archive.html">one more</a>, <a href="https://github.com/Windmill-hq/ARExperience">source code</a></p><h3>Don’t forget to give us your 👏 !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*s1cNDOTdQDQIgbtG" /></figure><figure><a href="https://docs.google.com/forms/d/1YBHAY792wL3OslxTQRqcIbRICNeKdeYSiSr2HyVrptU/edit"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*Wt2auqISiEAOZxJ-I7brDQ.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27a5d498f8b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ar-vr-journey/how-to-open-ar-portal-in-5-min-with-java-viro-core-27a5d498f8b">How to open AR Portal in 5 min with Java &amp; Viro Core</a> was originally published in <a href="https://medium.com/ar-vr-journey">AR/VR Journey: Augmented &amp; Virtual Reality Magazine</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>