Wiki source code of Base64 decoding

Last modified by Danniar Firdausy on 2024/09/17 21:20

Hide last authors
eMagiz 11.1 1 {{container}}
2 {{container layoutStyle="columns"}}
3 (((
Danniar Firdausy 16.7 4 In many cases, the standard tools in eMagiz are sufficient for manipulating data to meet the needs of external parties. However, there are instances where more complex functionality is required. This microlearning focuses on one such scenario, that is, to use base64 decoding for handling base64 encoded messages. By the end of this microlearning, you will understand how to implement this feature and when it's most useful, especially when working with encoded data that needs further manipulation.
eMagiz 1.1 5
eMagiz 11.1 6 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]].
eMagiz 1.1 7
8 == 1. Prerequisites ==
9
10 * Basic knowledge of the eMagiz platform
11
12 == 2. Key concepts ==
13
14 This microlearning centers around base64 decoding.
Danniar Firdausy 16.7 15 * With base64 decoding, we mean: turning the encoded string into a readable format that eMagiz can manipulate further downstream.
eMagiz 1.1 16
17 == 3. Base64 decoding ==
18
19 Most of the time, you can use the standard tooling of eMagiz to manipulate the data so that it makes sense for the (external) party that receives the data. However, sometimes there are cases in which you need a little bit of extra complexity. This microlearning will explain one of those more complex scenarios. In this microlearning, we will learn how to use base64 decoding on your (input) message. This functionality is beneficial when the message is encoded, but you need to manipulate part of the data.
20
21 Essential characteristics of this functionality are:
22
23 * Decoding (and encoding) of base64 strings take up additional memory (up to 33%)
24 * Separate integration for the base64 strings apart from metadata is advisable
25 * The component in eMagiz needs a base64 encoded string as input
26 * Multiple times encoding and decoding in the same integration is **not** advisable
27
Erik Bakker 14.1 28 The Base64 decode algorithm converts plain text into original data. Technically, it can be said that it converts six-bit bytes into eight-bit bytes. So when you have the base64 string of QUJD, you could manually convert this to a readable format. You can find an excellent explanation of how it works [[here>>https://base64.guru/learn/base64-algorithm/decode||target="blank"]]. Luckily for us, eMagiz will do all the heavy lifting, and we do not have to take out pen and paper.
eMagiz 1.1 29
30 In the remainder of this microlearning, we will look at how you could implement this logic within the eMagiz tooling.
31
32 === 3.1 Implementation ===
33
34 To implement this logic, we need to add a separate component to our flow at the point where we want to decode the base64 string. This is generally part of your processing. The most logical place would be a flow associated with processing (i.e., onramp, exit gate, event processor).
35
36 First, we need to navigate to the Create phase of eMagiz and open the flow in which we want to add this logic. Once you have opened your flow, you need to enter "Start editing" mode. This mode allows you to change the flow in question and add the logic to the transformation within the flow. When you have done so, it becomes time to add the base64 decode component to the flow.
37
eMagiz 11.1 38 [[image:Main.Images.Microlearning.WebHome@intermediate-data-handling-base64-decode--component.png]]
eMagiz 1.1 39
40 At the component level, you need to define the input and output channel. Afterward, you need to determine if your output will be bytes or string (on the Advanced tab). If you want to transform the content of the base64 encoded string via the tooling, the string option will make more sense. However, that option also uses up more memory. So depending on your use case, you should consider the whole dynamic when making your choice.
41
42 === 3.2 Use cases ===
43
44 Now that we know how to implement it, we can quickly look at possible use cases for this logic. We see this logic popping up mainly when dealing with attachments/files (i.e., pictures, pdf) within XML messages.
45
Eva Torken 16.1 46 == 4. Key takeaways ==
eMagiz 1.1 47
48 Essential characteristics of this functionality are:
49
Danniar Firdausy 16.7 50 * Decoding (and encoding) base64 strings can increase memory usage by up to 33%. Plan your integrations accordingly to avoid performance issues.
51 * It's advisable to keep base64 strings and metadata in separate integrations to prevent potential complications.
52 * The eMagiz component used for this process requires a base64 encoded string as input.
53 * Encoding and decoding multiple times in the same integration is **not** advisable.
eMagiz 1.1 54
Eva Torken 16.1 55 == 5. Suggested Additional Readings ==
eMagiz 1.1 56
57 If you are interested in this topic and want more information, please read the help text provided by eMagiz and the following links:
58
Danniar Firdausy 16.5 59 * [[Advanced Level (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.WebHome||target="blank"]]
60 ** [[Risk Management (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.Risk Management.WebHome||target="blank"]]
61 *** [[Considering the impact of message size (Explanation)>>Main.eMagiz Academy.Microlearnings.Advanced Level.Risk Management.advanced-risk-management-considering-impact-of-message-size-on-stability-of-the-solution||target="blank"]]
Danniar Firdausy 16.4 62 * [[Decode Base64 (Search Results)>>url:https://docs.emagiz.com/bin/view/Main/Search?sort=score&sortOrder=desc&highlight=true&facet=true&r=1&f_space_facet=0%2FMain.&l_space_facet=10&f_type=DOCUMENT&f_locale=en&f_locale=&f_locale=en&text=%22decode+base64%22||target="blank"]]
Danniar Firdausy 16.2 63 * [[Decode Algorithm (External)>>https://base64.guru/learn/base64-algorithm/decode||target="blank"]]
64 * [[Decode Online (External)>>https://www.base64decode.org/||target="blank"]]
Eva Torken 16.1 65 )))
eMagiz 1.1 66
eMagiz 11.1 67 ((({{toc/}}))){{/container}}
68 {{/container}}