Articles... Articles, Code, Downloads |
In this Section of the site, you can find brief introductory articles that describe the Source Code available to developers. You can download the code, modify it, and use it in your own applications. All the sources are freely available, with no restrictions, and can be recompiled however you see fit. Happy coding, everyone!
Inno Setup |
In this brief article I want to introduce Inno Setup, a Powerful and Versatile Installation Tool. Inno Setup is a Free and Open-Source Windows Installer developed by Jordan Russell and Martijn Laan. It was first released in 1997 and has since become one of the most popular installers in the world.
Let’s see what are the characteristics:
- Support for all file types, including executable files, library files, data files, etc.
- Support for all Windows operating systems, from Windows Vista onwards.
- Ability to create silent, custom, and network installations.
- Support for file compression, library registration, and font installation.
- Inno Setup is a very versatile tool that can be used to create installations of any type of software. It is particularly well-suited for creating custom software installations that need to meet specific needs.
More...
- It is free and open-source.
- It is very powerful and versatile.
- It is easy to learn and use.
- It is stable and reliable.
The Installer for the version of Speedcrypt is created using this tool. You can download the Source Code for the File I created for the Installation of Speedcrypt below:
Link: | Inno Script | Download: |
Inno Setup Version: 6
File : Speedcrypt.zip
MD5 : 84A70968 F37507FB 962369AF C275A966
SHA-1 : 08959C6F C5BFDD6D 40B38945 307194DA EA98C0B3
SHA-256 : F94C099F 6DDA0031 FA8B86A2 42869D52 24A3A4CC
A8BF487E 367F7C72 872E325E
Size : 1559 B
Generated by EasyHash
Once you have downloaded the Script I created, you only need to specify the Paths and the name of your Application. Clearly also the paths of the Files you want to include in your Setup, such as pre-installation, post-installation, and a License File. If you decide to use my script in your setups, a citation is greatly appreciated. Good Setup. Thank you all!.
XMLConfig |
In this brief article, I want to introduce the use of a configuration file in an application that needs to store settings and other program options. The source code generates a configuration file that you can configure and manipulate as follows:
- Inserting a key
- Changing a key
- Removing a key
- View the value of a key
- View the number of keys
In addition, the code proposes interaction of the configuration file with a ListView and other interesting options. You can enter your data through three text boxes, which are then combined into a single string that you can manipulate as you see fit.
Link: | c# language | Download: |
Microsoft Visual Studio 2022 (64 bit) Version: 17.11
File : XMLConfig.zip
MD5 : CE1D80ED FA385F55 24F8FB79 9BBB43BC
SHA-1 : 1AE31F4A 9D00B3BA 0F175E47 98DBB18A 91D62B36
SHA-256 : 3D0804EF 899C5CD0 7E258789 6BD8E20D C7B7CEEF
D3ED8F24 626E7C59 C074A1EA
Size : 139922 B
Generated by EasyHash
A well-structured configuration file is the best alternative to the famous Properties.Settings proposed in Visual Studio, which I personally strongly advise against. With your own configuration file, you can make your application free from any constraints and create all the archives you want. If you have downloaded the Source of Speedcrypt, you can personally check all the power of a self-generated configuration file. Good configuration!
ListView Icon |
I take this opportunity, in this article, in addition to the example on how to implement icons in the various rows of a ListView, to illustrate the procedure necessary to be able to insert images via code into a resource file and subsequently into an ImageList. Nothing new, except that, starting from the version of Microsoft Visual Studio Community 2022 (64 bit) 17.11.2 and later (I'm personally working with version 17.11.3), the approach to Resource Files containing images and other has completely changed.
Just thinking about loading images into an ImageList by directly using the component via the "collection item" is scary, for various reasons, including the difficulty in finding and reusing the images by the developer who will reuse the code. Before the above versions, you just had to create the Resource Class and then simply fill it by dragging images or whatever. The code to load images into the Imagelist component was also pretty simple. Let's look at an example:
imageList2.Images.Add(Nuvola_22._22_editcopy);
imageList2.Images.Add(Nuvola_22._22_edittrash);
imageList2.Images.Add(Nuvola_22._22_window_list);
As you can see in the example, three .png images are loaded into the ImageList1 container through the Resource Class called Nuvola_22. For each single image only one line of code.
All in all, a rather simple and convenient procedure. Once the images have been uploaded, they will then be distributed, in order of insertion, to the various components that interface with the ImageList1 container. As mentioned, since version 17.11.2 everything has changed starting from how the various Resource Classes are set and displayed. You get used to it quickly, at least to the graphical setting, problems arise when it comes to storing images. Here is how they are encapsulated in a Byte Type Structure:
Image Management with WPF
The image is then entrusted to the Windows Presentation Foundation (WPF) control and stored in the resource file that specifically belongs to the Nuvola_22 Class. Where does our problem lie?
Our problem, besides getting used to the new graphical interface and correctly interpreting the data flow, clearly lies in the fact that we need to update the code that will populate the ImageList1 container with our .png images, which we will use in various components. It's clear that we must absolutely stick to a single line of code for each image loaded into the container.
To achieve this, we need the Image.FromStream Method and the MemoryStream Class. Using the combination of these procedures, I composed the following code, meeting the set objectives and ensuring continuity with previous projects:
imageList1.Images.Add(Image.FromStream(new MemoryStream(Nuvola_16._16_package)));
imageList1.Images.Add(Image.FromStream(new MemoryStream(Nuvola_16._16_date)));
imageList1.Images.Add(Image.FromStream(new MemoryStream(Nuvola_16._16_kthememgr)));
You will find the above-described example in the example named ListView Icon, which you can download and adapt to your applications. The example, in addition to implementing the procedure described above to correctly interact with various resource classes, illustrates some interesting techniques to execute the following procedures:
- Alternate row colors
- extract and display icon from a file
- Insert an icon for each column of the ListView
- Inserting Images into an ImageList Container via Code
In the image on the right, you can see a screenshot of the example, giving you an idea of how you can customize a ListView by adding icons to each column of the grid. In the example, all the columns have an icon, but you can clearly choose which columns you want to contain the image based on your needs and your project. Please note that the icon in the field named ID is extracted from the files you put in the list.
Below you can download the application with the source code keeping in mind that I made it with the latest version of Visual Studio that you can download at the following Web Address.
Link: | c# language | Download: |
Microsoft Visual Studio 2022 (64 bit) Version: 17.11.3
File : ListView Icon.zip
MD5 : 4970E1CB 59B02CDC 61063703 DD88EBD3
SHA-1 : DD795327 EE92D72B 6220D1FE B14AB8B0 D10E80E3
SHA-256 : 31BCD525 CAF5A8CB A81A1186 E2D51E8A D4E6D645
63231DF1 D25C4880 8F55AF43
Size : 131072 B
Generated by EasyHash
I hope that the article and the related code will be useful to you. If that’s the case, please share it and make it available for as many people as possible to download. If you find my work interesting, don’t forget that you can also make a donation if you wish. This will help support my efforts. Thank you!
Fortuna Salt |
In this article, along with the corresponding example code, we will see how to create a SALT string to add to a password, making it more robust and reliable. To do this, I will use the Pseudo-Random Number Generator called Fortuna, my favorite, the conversion of the generated numbers through the Convert.ToBase64String Method, then we will add the obtained SALT to the entered password, and finally, we will derive the resulting string using the Blake 256 Bit HASH Function. In the example, you will find everything already correctly implemented and ready to use in your applications. Let's recap:
- We enter our Password
- We generate a pseudo-random number with Fortuna
- We transform the number into a string with Convert.ToBase64String Method
- We add the string to the password
- We perform the HASH derivation with Blake 256 Bit
In the example, I ensured that the password contains at least six characters in order to start the procedure via a button labeled Start. Once the button is active, you can click it multiple times to observe the continuously changing values. The best part? This is achieved with just five lines of code. Here they are:
//FortunaPRNG
var provider = new Provider();
//Blake 256
Blake256 blake = new Blake256();
txtFort.Text = Convert.ToString(provider.GetRandomInt()).Replace("-", "");
txtSalt.Text = Convert.ToBase64String(Encoding.Default.GetBytes(Convert.ToString(txtFort.Text))) + txtPsw.Text;
txtBlk.Text = BitConverter.ToString(blake.ComputeHash(Encoding.Default.GetBytes(txtSalt.Text))).ToLower().Replace("-", "");
Surely, in this code, you may have noticed especially if you are an experienced programmer the absence of variables, except for formal declarations. Wherever possible, I avoid declaring and using variables of any kind, preferring instead to rely on conversions and encodings. In my opinion, this makes the code much smoother, faster in execution, easier to read, and more elegant in appearance. Of course, I don't claim to hold the ultimate truth, this is just my personal opinion, which you can take as advice or ignore if you have alternative methods and tools. Opinions and suggestions are, of course, welcome. Below is the source code for the example:
Link: | c# language | Download: |
Microsoft Visual Studio 2022 (64 bit) Version: 17.11.3
File : Fortuna Salt.zip
MD5 : 09311ACA C94ACA34 22F31BCE AC02F5DD
SHA-1 : 1361C242 9A1ADE99 9B1899AB 2441AEBB F1C5EEF1
SHA-256 : F3E24933 67E0BE80 FB54E985 B6D85252 FFB814EF
25AFCD30 123DE4F3 D2827683
Size : 75744 B
Generated by EasyHash
If you decide to use the code from this example in your projects, make sure to create a single procedure that can be accessed by every unit in the project. Regarding this, you can analyze the source code of Speedcrypt in the Settings component. You'll find all the code you need there. Happy SALT to everyone!
AES String Crypto |
In this brief article, we introduce string encryption using the AES Algorithm with a 256-bit key. Using a Pseudo-Random Number Generator (DRBG), we generate a string that can be used as a SALT via the Convert.ToBase64String Method. We are already familiar with this process from the previous article, where we generated a SALT using the Pseudo-Random Number Generator known as Fortuna. Once the string is generated, we simply encrypt and decrypt it using the aforementioned AES Algorithm. In this example, we will also use one of my favorite HASH Functions, Blake 256, to derive the entered password. As usual, the example is accompanied by source code that you can freely download, modify, and implement in your applications. Let's summarize:
- We enter a Password
- We generate a SALT for our Password
- We derive the Password with the Blake 256 HASH Function
- We generate a Random Peseudo Number
- We transform the number into a string using the Convert.ToBase64String Method (SALT)
- We encrypt the string with the AES Algorithm with a 256 Bit key
In this example as well, I ensured that the password contains at least six characters, which, once entered, activate the button that starts the entire procedure. You will then be able to encrypt and decrypt the string value as you wish. Again, the lines of code are very few only two for the string decryption process. Specifically, both processes are enclosed within a try-catch block to catch any Exceptions. I have not assigned any messages to the Exceptions, leaving them silent, but feel free to implement the code you want, especially in your applications. Personally, I often use Silent Exceptions, especially in certain situations, as it’s better for the data flow to continue without requiring user intervention.
Link: | c# language | Download: |
Microsoft Visual Studio 2022 (64 bit) Version: 17.11.3
File : AES String Crypto.zip
MD5 : 686117D1 BA16C15A 1D52B341 B6C28E27
SHA-1 : 122BA676 55FF3456 83869BEC 2B0CC94C B2B04BC4
SHA-256 : 972CFC86 69550753 0751A4C7 C40A204E A9B4328B
6B71447B EE52D440 CD2541C8
Size : 76030 B
Generated by EasyHash
I conclude this article by once again stating that I do not possess the ultimate truth. Cryptography is one of the most difficult subjects, and the fact that I have studied it for many years does not protect me from potential mistakes. This is one of the many reasons why our programs have Open Source Code: it must be examined to ensure that everything has been correctly implemented. If you are experienced cryptographers and find any errors in my code, I kindly ask you to let me know so that I can make the necessary corrections and, most importantly, provide the community with technically correct, efficient, and high-performance code. Thank you very much!