<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>decode Archive - Robert Skibbe</title>
	<atom:link href="https://robbelroot.de/blog/tag/decode/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>alias RobbelRoot – Freelance Full Stack Developer .NET</description>
	<lastBuildDate>Tue, 12 Sep 2023 16:28:48 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://robbelroot.de/wp-content/uploads/2020/12/cropped-favicon-32x32.png</url>
	<title>decode Archive - Robert Skibbe</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>rskibbe.Encryption.Base64 – A Base64 implementation</title>
		<link>https://robbelroot.de/blog/rskibbe-encryption-base64-implementation/</link>
					<comments>https://robbelroot.de/blog/rskibbe-encryption-base64-implementation/#comments</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Sat, 09 Sep 2023 23:28:39 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[NuGet Packages]]></category>
		<category><![CDATA[rskibbe]]></category>
		<category><![CDATA[rskibbe.Encryption]]></category>
		<category><![CDATA[rskibbe.Encryption.Base64]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[decode]]></category>
		<category><![CDATA[decoding]]></category>
		<category><![CDATA[encode]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[infrastructure]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=15924</guid>

					<description><![CDATA[<p>What is rskibbe.Encryption.Base64? As the name already suggests, it is a sub-package of the &#8222;rskibbe.Encryption&#8220; infrastructure package implementing the Base64 encryption (encoding). This means, it helps you encrypt / encode or decrypt / decode data with the Base64 algorithm. I needed some common denominator for my apps and I didn&#8217;t &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/rskibbe-encryption-base64-implementation/">rskibbe.Encryption.Base64 – A Base64 implementation</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/09/rskibbe.Encryption.Base64-A-Base64-encryption-implementation-sub-package.png"><img fetchpriority="high" decoding="async" width="640" height="360" src="https://robbelroot.de/wp-content/uploads/2023/09/rskibbe.Encryption.Base64-A-Base64-encryption-implementation-sub-package.png" alt="rskibbe.Encryption.Base64 - A Base64 encryption implementation sub-package" class="wp-image-15929" title="rskibbe.Encryption.Base64 - A Base64 encryption implementation sub-package"/></a><figcaption class="wp-element-caption">rskibbe.Encryption.Base64 &#8211; A Base64 encryption implementation sub-package</figcaption></figure>






<h2 class="wp-block-heading">What is rskibbe.Encryption.Base64?</h2>



<p>As the name already suggests, it is a sub-package of the &#8222;rskibbe.Encryption&#8220; infrastructure package implementing the Base64 encryption (encoding). This means, it helps you encrypt / encode or decrypt / decode data with the Base64 algorithm. I needed some common denominator for my apps and I didn&#8217;t want to start over and over again. I didn&#8217;t want to have separated code bases and <strong><a href="https://robbelroot.de/blog/rskibbe-encryption-an-infrastructure-for-encoding-decoding-things/" target="_blank" rel="noreferrer noopener">some sort of common base</a></strong> &#8211; so I came up with these two libraries.</p>


<p class="rr-alert info" style="background:#e3f7fc;"><img decoding="async" alt="Info notice" src="https://robbelroot.de/wp-content/themes/pinboard-child/imgs/info.png"><span style="color:black;align-self: center;">Keep in mind that Base64 rather is an Encoding than an Encryption, but in terms of this lib, I called it Encryption, because you can transfer from A to B and back from B to A.</span></p>



<h2 class="wp-block-heading">Quick example</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2022/11/Quick-example-for-rskibbe.I18n-translating-Winforms-and-WPF-applications.png"><img decoding="async" width="640" height="360" src="https://robbelroot.de/wp-content/uploads/2022/11/Quick-example-for-rskibbe.I18n-translating-Winforms-and-WPF-applications.png" alt="A quick example for rskibbe.Encryption.Base64 based encryption" class="wp-image-12234" title="A quick example for rskibbe.Encryption.Base64 based encryption"/></a><figcaption class="wp-element-caption">A quick example for rskibbe.Encryption.Base64 based encryption</figcaption></figure>



<h3 class="wp-block-heading">Step 1 – Install the package</h3>



<p>Open the NuGet Package Manager and execute the following commands (or install it by GUI). This command will install the package to enable you using its code.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="NuGet Paket-Manager-Konsole" data-enlighter-group="">Install-Package rskibbe.Encryption
Install-Package rskibbe.Encryption.Base64</pre>



<h3 class="wp-block-heading">Step 2 – Instant usage without DI conceptions, etc.</h3>



<p>If you &#8222;just want to get it going&#8220; you can – I provided a singleton property for that. Keep in mind though, that you should think about using the more DI / IoC based approach (creating and sharing instances over DI and using like the IEncryptor or inherited interfaces around your app) in bigger apps. This can be especially helpful, if you create Encoders for specific and different problems.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="singleton-usage">// encoding
// 1. using the normal version (uses UTF8 by default)
string encodedText = Base64Encryptor.Instance.Encode("hello!");

// or 2. changing the encoding globally (for the singleton instance)
Base64Encryptor.Instance.Encoding = System.Text.Encoding.&lt;WhateverEncodingYouLike>;
string encodedText = Base64Encryptor.Instance.Encode("hello!");

// decoding
string decodedText = Base64Encryptor.Instance.Decode("aGVsbG8h");</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="singleton-usage">' encoding
' 1. using the normal version (uses UTF8 by default)
Dim encodedText As String = Base64Encryptor.Instance.Encode("hello!")

' or 2. changing the encoding globally (for the singleton instance)
Base64Encryptor.Instance.Encoding = System.Text.Encoding.&lt;WhateverEncodingYouLike>
Dim encodedText As String = Base64Encryptor.Instance.Encode("hello!")

' decoding
Dim decodedText As String = Base64Encryptor.Instance.Decode("aGVsbG8h")</pre>



<h3 class="wp-block-heading">Step 3 – Create an instance of the specific encryptor</h3>



<p>As we are using the Base64 implementation as encryption algorithm, you will need to create a corresponding object instance of the class &#8222;Base64Encryptor&#8220;. You can also specify an encoding (<strong><a href="https://learn.microsoft.com/de-de/dotnet/api/system.text.encoding?view=net-7.0" target="_blank" rel="noreferrer noopener">System.TextEncoding</a></strong>) while constructing. The encryptor will use UTF8 as default / if not specified.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="creating-an-instance">// longer version
Base64Encryptor base64Encryptor = new Base64Encryptor();

// or short..
var base64Encryptor = new Base64Encryptor();</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="creating-an-instance">' longer version
Dim base64Encryptor As Base64Encryptor = new Base64Encryptor()

' or short..
Dim base64Encryptor = New Base64Encryptor()</pre>



<h3 class="wp-block-heading">Step 4 – Using the encryptor</h3>



<p>With our common denominator / interface coming from the base package &#8222;rskibbe.Encryption&#8220;, we can now just call the corresponding functions.</p>



<h4 class="wp-block-heading">Encrypting / Encoding</h4>



<p>Encoding raw text to their Base64 counterpart is now pretty easy as you can just call the &#8222;Encode&#8220; method on your created &#8222;Base64Encryptor&#8220; instance – implementing the &#8222;IEncryptor&#8220; interface.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="enocding">// having our instance from the previous examples
string plainText = "hello!";
string encodedText = base64Encryptor.Encode(plainText);

// will output "aGVsbG8h"
System.Diagnostics.Debug.WriteLine(encodedText);</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="enocding">' having our instance from the previous examples
Dim plainText As String = "hello!"
Dim encodedText As String = base64Encryptor.Encode(plainText)

' will output "aGVsbG8h"
System.Diagnostics.Debug.WriteLine(encodedText)</pre>



<h4 class="wp-block-heading">Decrypting / Decoding</h4>



<p>Decoding is just as simple as encoding, just call the corresponding &#8222;Decode&#8220; method being implemented from the interface as well.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="C#" data-enlighter-group="decoding">// having our instance from the previous examples
string encodedText = "aGVsbG8h";
string text = base64Encryptor.Decode(encodedText);

// will output "hello!"
System.Diagnostics.Debug.WriteLine(text);</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="VB.NET" data-enlighter-group="decoding">' having our instance from the previous examples
Dim encodedText As String = "aGVsbG8h"
Dim text As String = base64Encryptor.Decode(encodedText)

' will output "hello!"
System.Diagnostics.Debug.WriteLine(text)</pre>
<p>Der Beitrag <a href="https://robbelroot.de/blog/rskibbe-encryption-base64-implementation/">rskibbe.Encryption.Base64 – A Base64 implementation</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/rskibbe-encryption-base64-implementation/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>rskibbe.Encryption – An infrastructure for encoding / decoding things</title>
		<link>https://robbelroot.de/blog/rskibbe-encryption-an-infrastructure-for-encoding-decoding-things/</link>
					<comments>https://robbelroot.de/blog/rskibbe-encryption-an-infrastructure-for-encoding-decoding-things/#comments</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Sat, 09 Sep 2023 22:10:08 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[NuGet Packages]]></category>
		<category><![CDATA[rskibbe]]></category>
		<category><![CDATA[rskibbe.Encryption]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[decode]]></category>
		<category><![CDATA[decoding]]></category>
		<category><![CDATA[encode]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[infrastructure]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=15896</guid>

					<description><![CDATA[<p>What is rskibbe.Encryption? In software development you most likely want to create a clean and easy maintainable code base. With &#8222;rskibbe.Encryption&#8220; you create that common base infrastructure for things that depend on encryption processes like encoding / decoding. Just imagine this package being installed and telling your (for example) viewmodels &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/rskibbe-encryption-an-infrastructure-for-encoding-decoding-things/">rskibbe.Encryption – An infrastructure for encoding / decoding things</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/09/rskibbe.Encryption-A-common-base-infrastructure-package-for-things-that-depend-on-encryption.png"><img decoding="async" width="640" height="360" src="https://robbelroot.de/wp-content/uploads/2023/09/rskibbe.Encryption-A-common-base-infrastructure-package-for-things-that-depend-on-encryption.png" alt="rskibbe.Encryption - A common base infrastructure package for things that depend on encryption" class="wp-image-15902" title="rskibbe.Encryption - A common base infrastructure package for things that depend on encryption"/></a><figcaption class="wp-element-caption">rskibbe.Encryption &#8211; A common base infrastructure package for things that depend on encryption</figcaption></figure>






<h2 class="wp-block-heading">What is rskibbe.Encryption?</h2>



<p>In software development you most likely want to create a clean and easy maintainable code base. With &#8222;rskibbe.Encryption&#8220; you create that common base infrastructure for things that depend on encryption processes like encoding / decoding. Just imagine this package being installed and telling your (for example) viewmodels or services: &#8222;Hey, you depend on something, which is able to encode / encrypt data / both&#8220; or &#8222;Hey, you will get something, which is able to decode data&#8220;.</p>



<p>Write your custom implementation for that (or install the available ones) and boom &#8211; no need to have 10 different types in your projects, which all actually should refer to a common base. For sure, there will be more sub-packages later!</p>



<h2 class="wp-block-heading">Quick example</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2022/11/Quick-example-for-rskibbe.I18n-translating-Winforms-and-WPF-applications.png"><img loading="lazy" decoding="async" width="640" height="360" src="https://robbelroot.de/wp-content/uploads/2022/11/Quick-example-for-rskibbe.I18n-translating-Winforms-and-WPF-applications.png" alt="A quick example for rskibbe.Encryption based encryption" class="wp-image-12234" title="A quick example for rskibbe.Encryption based encryption"/></a><figcaption class="wp-element-caption">A quick example for rskibbe.Encryption based encryption</figcaption></figure>



<h3 class="wp-block-heading">Step 1 – Install the package</h3>



<p>Open the NuGet Package Manager and execute the following commands (or install it by GUI). This command will install the package to enable you using its code.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="NuGet Paket-Manager-Konsole" data-enlighter-group="">Install-Package rskibbe.Encryption</pre>



<h3 class="wp-block-heading">Step 2 – Install existing or create manual implementations</h3>



<p>Remember: &#8222;rskibbe.Encryption&#8220; is only a base package, that is used, to create a common infrastructure between apps. There will be more sub-packages coming &#8211; but feel (of course) free to create your own implementations.</p>



<h4 class="wp-block-heading">Existing implementations</h4>



<p>If you just want to get it going with like Base64, <strong><a href="https://robbelroot.de/blog/rskibbe-encryption-base64-implementation/" target="_blank" rel="noreferrer noopener">take a look at for example &#8222;rskibbe.Encryption.Base64&#8220;</a></strong> for the Base64 &#8222;IEncryptor&#8220; interface implementation.</p>



<h3 class="wp-block-heading">Custom implementation</h3>



<p>After installing the base package, you can now start implementing the things required for the interfaces. Please make sure, to check out <strong><a href="#detailed-explanation">the detailed explanation</a></strong> to understand the things behind this package. There could be different approaches, like if you only want something, which is able to decode something, just implement the &#8222;IDecoder&#8220; interface. If &#8211; on the other hand &#8211; you need something which is able to encode and decode, then implement the &#8222;IEncryptor&#8220; interface. You could then use typical DI to inject your dependencies into the target models, services, etc.</p>



<h3 class="wp-block-heading">Step 3 – Use the implementation</h3>



<p>After you either downloaded an existing implementation like the &#8222;<strong><a href="https://robbelroot.de/blog/rskibbe-encryption-base64-implementation/" target="_blank" rel="noreferrer noopener">rskibbe.Encryption.Base64</a></strong>&#8220; or implemented your own one. Create an instance and call the corresponding &#8222;Encode&#8220;, &#8222;Decode&#8220; methods on the object.</p>



<h2 class="wp-block-heading" id="detailed-explanation">Detailed explanation</h2>



<figure class="wp-block-image size-full"><a href="https://robbelroot.de/wp-content/uploads/2023/09/Infrastructure-Diagram-for-classes-and-interfaces-–-rskibbe.Encryption.png"><img loading="lazy" decoding="async" width="649" height="592" src="https://robbelroot.de/wp-content/uploads/2023/09/Infrastructure-Diagram-for-classes-and-interfaces-–-rskibbe.Encryption.png" alt="Infrastructure Diagram for classes and interfaces – rskibbe.Encryption" class="wp-image-15982" title="Infrastructure Diagram for classes and interfaces – rskibbe.Encryption"/></a><figcaption class="wp-element-caption">Infrastructure Diagram for classes and interfaces – rskibbe.Encryption</figcaption></figure>



<p>If you take a look at the diagram / image, you can see some things explaining the library in more detail. I mean, it&#8217;s not that big anyways, but&#8230; As this is only an infrastructure, you won&#8217;t see any implementation / model classes. Only the exception classes are (more or less provided) to be directly used – the exception, hah.</p>



<h3 class="wp-block-heading">Common conception:</h3>



<p>The idea behind this package is to structure the (soon) following things when talking about encryption. Keep in mind, that the term &#8222;encryption&#8220; isn&#8217;t to be mixed with the term &#8222;hashing&#8220;! Back to the encryption side of things, there are:</p>



<ul class="wp-block-list">
<li>&#8222;things&#8220; being able to <strong>encode data</strong></li>



<li>&#8222;things&#8220; being able to <strong>decode data</strong></li>



<li>and &#8222;things&#8220; being able to do <strong>both tasks combined</strong></li>
</ul>



<h3 class="wp-block-heading">Encoders</h3>



<p>The most common task when talking about &#8222;encryption&#8220; would be the encoding / encryption of provided data. So I called the <strong>thing which is able to &#8222;encode&#8220; data – Encoder</strong>. Therefore, the &#8222;IEncoder&#8220; interface came to life having only this one method &#8222;Encode&#8220;.</p>



<h3 class="wp-block-heading">Decoders</h3>



<p>In terms of encryption (again &#8211; not hashing!) you wouldn&#8217;t have pretty much out of it, when you can encode things but never getting them back to the original. This is where the term &#8222;Decoder&#8220; and the corresponding interface &#8222;IDecoder&#8220; are coming into play. As the name suggests, <strong>a decoder has only one job – decoding things</strong>! Therefore the interface &#8222;IDecoder&#8220; came to life.</p>



<h3 class="wp-block-heading">Encryptor</h3>



<p>In the end, there will be &#8222;things&#8220; that <strong>can do both works – encoding and also decoding</strong>. I called them &#8222;Encryptors&#8220; in my little world here. I was racking my brain to find a better term for it, but couldn&#8217;t. I though about something like &#8222;Cypher&#8220;, &#8222;XyManager&#8220; but these sucked even more, so&#8230;</p>



<h3 class="wp-block-heading">Exceptions</h3>



<p>For sure, there can be and will be things going wrong. Some may lead to a fatal exit of your app, some aren&#8217;t that bad. I&#8217;ve added two base classes for Exception handling, signaling: &#8222;Hey, there went something wrong encoding / decoding your provided data&#8220;. You can therefore throw an &#8222;EncodingException&#8220; when something went wrong while encoding and a &#8222;DecodingException&#8220; for decoding problems. </p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/rskibbe-encryption-an-infrastructure-for-encoding-decoding-things/">rskibbe.Encryption – An infrastructure for encoding / decoding things</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/rskibbe-encryption-an-infrastructure-for-encoding-decoding-things/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
