Skip to main content

Posts

Showing posts from April, 2015

C# Encrypt & Decrypt Serialized Object

Hi peeps! hoh! this is the thing that ive been trying to do for 2-3 days! encountered quite a number of problems! so guys this thing really forced me to google a lot on exception that thrown to me. I hope This tutorial really helps those who trying to accomplishing the same objective and encountered bugs along the way. Objective : To serialized object to a memory stream and encrypt the stream then only write the stream into a file. Question : Why is it important to Encrypt our data? isnt serialization is sufficient enough? Answer : As i posted in my serialization tutorial we can see the data that we serialized into a file is not secure enough. Sensitive data are still exposed. Left : Encrypted data Right: Non Encrypted data I hope you guys been patient to go tru step by step tutorial that i provided as this implementation if there are missing codes or steps. you wll encountered numerous exception later. so be patient and keep reading through. 1. Declare our global

C# Deserialization tutorial : Deserialize file stream object

Hi peeps, this is a continued post from serialization tutorial . walaah. you guys already know how to do serialization. Ok now, we going to read our created file and store it in filestream and deserialize it back into our data object. 1. Ensure that we are pointing to the right path. 2. Read our file, notice that we are using FileMode.Open 3. Instantiate our DataObjectSerializable instance. We going to store back the data that we deserialize into it. 4. Deserialize our file stream and assign the returned value to our dataObject. 5. Print out the dataObject data values to check. Done! Run the program. The output Hope this helps. For full code you can view it from my github repo here: https://github.com/aliaramli/c-tutorials/tree/master/Serialization/SerializationExample/SerializationExample

C# Serialization Tutorial Part 1 : Serialize object in file stream

Hello Peeps. Came across this topic while doing our game saving data feature. this post only cover basic serialization. basically serialization help us to convert our object into stream of bytes so that our object can be stored or transmit over in memory/file/database. before we can proceed with the serialization tutorial, we need to set the user permission to our target folder path. 1. Set the folder path to be accessible and can be override. This step is to avoid our program/apps from throwing unauthorizedaccessexception.    - for my scenario, im choosing the path of D:\SelfLearning\c#\Serialization to store my data file. Right click the target folder, select on Security tab Select on Users and give full control or modify permission to the user. 2. Now we are going to write our code. First we need to setup our folder path. 3. We going to create our file.  In this tutorial we are using FileStream type, other then FileStream, we can make use of MemoryStream i