<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saidur Rahman Akash</title>
    <description>The latest articles on DEV Community by Saidur Rahman Akash (@imakash).</description>
    <link>https://dev.to/imakash</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1046604%2F04d299b9-f775-4614-b9ca-d83820d70813.jpeg</url>
      <title>DEV Community: Saidur Rahman Akash</title>
      <link>https://dev.to/imakash</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/imakash"/>
    <language>en</language>
    <item>
      <title>Hashing and Salting Passwords in C#</title>
      <dc:creator>Saidur Rahman Akash</dc:creator>
      <pubDate>Mon, 11 Aug 2025 05:03:03 +0000</pubDate>
      <link>https://dev.to/imakash/hashing-and-salting-passwords-in-c-52cm</link>
      <guid>https://dev.to/imakash/hashing-and-salting-passwords-in-c-52cm</guid>
      <description>&lt;p&gt;In the realm of cybersecurity, protecting user passwords is paramount to safeguarding sensitive information. Hashing and salting are fundamental techniques employed to enhance the security of stored passwords. In C#, developers can utilize these practices to fortify their authentication systems against unauthorized access and data breaches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hashing Passwords: A One-Way Journey&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user creates an account or updates their password, hashing comes into play. Hashing is a process of transforming a plaintext password into an irreversible, fixed-length string of characters. In C#, developers often use cryptographic hash functions like SHA-256 or bcrypt for this purpose. The resulting hash is unique to each password, making it infeasible for attackers to reverse the process and retrieve the original password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static string HashPassword(string password, byte[] salt)
        {
            using (var sha256 = new SHA256Managed())
            {
                byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
                byte[] saltedPassword = new byte[passwordBytes.Length + salt.Length];

                // Concatenate password and salt
                Buffer.BlockCopy(passwordBytes, 0, saltedPassword, 0, passwordBytes.Length);
                Buffer.BlockCopy(salt, 0, saltedPassword, passwordBytes.Length, salt.Length);

                // Hash the concatenated password and salt
                byte[] hashedBytes = sha256.ComputeHash(saltedPassword);

                // Concatenate the salt and hashed password for storage
                byte[] hashedPasswordWithSalt = new byte[hashedBytes.Length + salt.Length];
                Buffer.BlockCopy(salt, 0, hashedPasswordWithSalt, 0, salt.Length);
                Buffer.BlockCopy(hashedBytes, 0, hashedPasswordWithSalt, salt.Length, hashedBytes.Length);

                return Convert.ToBase64String(hashedPasswordWithSalt);
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Salting: Adding a Dash of Complexity&lt;/strong&gt;&lt;br&gt;
Hashing alone, while effective, can be vulnerable to attacks like rainbow table attacks. This is where salting comes in. A salt is a random value unique to each user. It is combined with the password before hashing, introducing an additional layer of complexity. Even if two users have the same password, their hashes will differ due to the unique salts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static byte[] GenerateSalt()
        {
            using (var rng = new RNGCryptoServiceProvider())
            {
                byte[] salt = new byte[16]; // Adjust the size based on your security requirements
                rng.GetBytes(salt);
                return salt;
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Storing in C#: Database Integration&lt;/strong&gt;&lt;br&gt;
In C#, the resulting hashed password and the salt can be stored in a database. Retrieving and verifying passwords during login involves fetching the salt, combining it with the entered password, hashing the result, and comparing it with the stored hash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class UserDTO
    {
        public string UserName { get; set; }
        public string MobileNo { get; set; }
        public string Password { get; set; }
        public string ConfirmPassword { get; set; }
    }

public interface IHashingPassword
    {
        public Task&amp;lt;string&amp;gt; CreateUser(UserDTO create);
        public Task&amp;lt;string&amp;gt; UserVerify(UserDTO verify);
    }

public class HashingPassword : IHashingPassword
{
   private readonly DbContextCom _dbContext;
   public HashingPassword(DbContextCom dbContext)
        {
            _dbContext = dbContext;
        }

   public async Task&amp;lt;string&amp;gt; CreateUser(UserDTO create)
        {
            string password = create.ConfirmPassword;

            byte[] saltBytes = GenerateSalt();
            // Hash the password with the salt
            string hashedPassword = HashPassword(password, saltBytes);
            string base64Salt = Convert.ToBase64String(saltBytes);

            byte[] retrievedSaltBytes = Convert.FromBase64String(base64Salt);

            var user = new Models.Usertest
            {
                ConfirmPassword = hashedPassword,
                Email = "",
                IsActive = true,
                LastActiondatetime = DateTime.Now,
                Mobile = create.MobileNo,
                Password = base64Salt,
                UserName = create.UserName,
                Salt = retrievedSaltBytes
            };
            _dbContext.Usertests.AddAsync(user);
            await _dbContext.SaveChangesAsync();

            return "User added successfully";
        }

        public async Task&amp;lt;string&amp;gt; UserVerify(UserDTO verify)
        {

            // In a real scenario, you would retrieve these values from your database
            var user = _dbContext.Usertests.Where(x =&amp;gt; x.Mobile == verify.MobileNo).Select(x =&amp;gt; x).FirstOrDefault();

            string storedHashedPassword = user.ConfirmPassword;// "hashed_password_from_database";
            //string storedSalt = user.Salt; //"salt_from_database";
            byte[] storedSaltBytes = user.Salt;
            string enteredPassword = verify.ConfirmPassword; //"user_entered_password";

            // Convert the stored salt and entered password to byte arrays
            // byte[] storedSaltBytes = Convert.FromBase64String(user.Salt);
            byte[] enteredPasswordBytes = Encoding.UTF8.GetBytes(enteredPassword);

            // Concatenate entered password and stored salt
            byte[] saltedPassword = new byte[enteredPasswordBytes.Length + storedSaltBytes.Length];
            Buffer.BlockCopy(enteredPasswordBytes, 0, saltedPassword, 0, enteredPasswordBytes.Length);
            Buffer.BlockCopy(storedSaltBytes, 0, saltedPassword, enteredPasswordBytes.Length, storedSaltBytes.Length);

            // Hash the concatenated value
            string enteredPasswordHash = HashPassword(enteredPassword, storedSaltBytes);

            // Compare the entered password hash with the stored hash
            if (enteredPasswordHash == storedHashedPassword)
            {
                return "Password is correct.";
            }
            else
            {
                return "Password is incorrect.";
            }
        }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion: Bolstering Security&lt;/strong&gt;&lt;br&gt;
Hashing and salting passwords in C# are essential practices for building robust and secure authentication systems. By incorporating these techniques, developers can significantly mitigate the risk of unauthorized access, ensuring the confidentiality of user credentials in the ever-evolving landscape of cybersecurity.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>security</category>
      <category>hashingalgorithm</category>
      <category>hashingandsalting</category>
    </item>
    <item>
      <title>dotnet beginner guidelines</title>
      <dc:creator>Saidur Rahman Akash</dc:creator>
      <pubDate>Sun, 07 Jul 2024 08:55:52 +0000</pubDate>
      <link>https://dev.to/imakash/dotnet-beginner-guidelines-40e9</link>
      <guid>https://dev.to/imakash/dotnet-beginner-guidelines-40e9</guid>
      <description>&lt;p&gt;1/ Object-Oriented Programming (OOP) is an essential paradigm for every programmer. It empowers developers with a powerful set of tools and concepts to design and build software systems efficiently. Without OOP, it's like being a soldier without a gun - missing out on a fundamental approach that enhances code organization, reusability, and maintainability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.c-sharpcorner.com/UploadFile/84c85b/object-oriented-programming-using-C-Sharp-net/" rel="noopener noreferrer"&gt;https://www.c-sharpcorner.com/UploadFile/84c85b/object-oriented-programming-using-C-Sharp-net/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=7eA70JjiZ9c" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=7eA70JjiZ9c&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=TS4GwQkjWPU" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=TS4GwQkjWPU&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2/ Structure with C# (Need a basic understanding of data structure)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;a href="https://learn.microsoft.com/en-us/dotnet/standard/collections/" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/dotnet/standard/collections/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/adavidoaiei/fundamental-data-structures-and-algorithms-in-c-4ocf"&gt;https://dev.to/adavidoaiei/fundamental-data-structures-and-algorithms-in-c-4ocf&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3/ Algorithms with C# (Need basic understanding)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3resource.com/csharp-exercises/basic-algo/index.php" rel="noopener noreferrer"&gt;https://www.w3resource.com/csharp-exercises/basic-algo/index.php&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4/ C# Basic topics (for more understanding please google it.)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/cs/index.php" rel="noopener noreferrer"&gt;https://www.w3schools.com/cs/index.php&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.guru99.com/c-sharp-tutorial.html" rel="noopener noreferrer"&gt;https://www.guru99.com/c-sharp-tutorial.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tutorialspoint.com/Asynchronous-programming-in-Chash-using-Async-and-Await-keyword" rel="noopener noreferrer"&gt;https://www.tutorialspoint.com/Asynchronous-programming-in-Chash-using-Async-and-Await-keyword&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=gfkTfcpWqAY&amp;amp;t=10s&amp;amp;ab_channel=ProgrammingwithMosh" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=gfkTfcpWqAY&amp;amp;t=10s&amp;amp;ab_channel=ProgrammingwithMosh&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5/ C# Basic to advance topics (not necessary as a beginner if you know this thing that’s a plus)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.tutorialspoint.com/csharp/csharp_tutorial.pdf" rel="noopener noreferrer"&gt;https://www.tutorialspoint.com/csharp/csharp_tutorial.pdf&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=jcn5uCZAk2w&amp;amp;list=PLLWMQd6PeGY12yNE714jffLFnMVZCwvvZ" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=jcn5uCZAk2w&amp;amp;list=PLLWMQd6PeGY12yNE714jffLFnMVZCwvvZ&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;6/ C# in Details (if you want to know more about C# then google it because it's free.)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/playlist?list=PLUOequmGnXxPjam--7GAls6Tb1fSmL9mL" rel="noopener noreferrer"&gt;https://www.youtube.com/playlist?list=PLUOequmGnXxPjam--7GAls6Tb1fSmL9mL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;7/ Basic SQL Query (SQL (Structured Query Language) plays a crucial role when working with C# and databases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.sqlservertutorial.net/sql-server-basics/" rel="noopener noreferrer"&gt;https://www.sqlservertutorial.net/sql-server-basics/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.guru99.com/ms-sql-server-tutorial.html" rel="noopener noreferrer"&gt;https://www.guru99.com/ms-sql-server-tutorial.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=h0nxCDiD-zg&amp;amp;t=1377s&amp;amp;ab_channel=KevinStratvert" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=h0nxCDiD-zg&amp;amp;t=1377s&amp;amp;ab_channel=KevinStratvert&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;You can practice SQL problems in HackerRank - &lt;a href="https://www.hackerrank.com/domains/sql" rel="noopener noreferrer"&gt;https://www.hackerrank.com/domains/sql&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;8/ MVC framework with C# &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=E7Voso411Vs&amp;amp;ab_channel=ProgrammingwithMosh" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=E7Voso411Vs&amp;amp;ab_channel=ProgrammingwithMosh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.guru99.com/mvc-tutorial.html" rel="noopener noreferrer"&gt;https://www.guru99.com/mvc-tutorial.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;9/ LINQ (Language-Integrated Query) This is also a must-know topic for those who want to work with dotnet.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.tutorialsteacher.com/linq" rel="noopener noreferrer"&gt;https://www.tutorialsteacher.com/linq&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/playlist?list=PL6n9fhu94yhWi8K02Eqxp3Xyh_OmQ0Rp6" rel="noopener noreferrer"&gt;https://www.youtube.com/playlist?list=PL6n9fhu94yhWi8K02Eqxp3Xyh_OmQ0Rp6&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;You can find some awesome projects to understand more about MVC with C#&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/SR-Akash/TMS-Transport-Management-System" rel="noopener noreferrer"&gt;https://github.com/SR-Akash/TMS-Transport-Management-System&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/SR-Akash/Coaching_Management" rel="noopener noreferrer"&gt;https://github.com/SR-Akash/Coaching_Management&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/SR-Akash/School-Account-Management" rel="noopener noreferrer"&gt;https://github.com/SR-Akash/School-Account-Management&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10/ Understanding Rest API - Understanding REST API is crucial for developing web applications using ASP.NET Core. REST is an architectural style that defines a set of principles and constraints for building scalable, reliable, and loosely coupled web services.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=6pn70EsvoWk&amp;amp;list=PLz2xCPyrlKZYNqJW1-_zp83fJq-G991cO" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=6pn70EsvoWk&amp;amp;list=PLz2xCPyrlKZYNqJW1-_zp83fJq-G991cO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/playlist?list=PLUOequmGnXxOgmSDWU7Tl6iQTsOtyjtwU" rel="noopener noreferrer"&gt;https://www.youtube.com/playlist?list=PLUOequmGnXxOgmSDWU7Tl6iQTsOtyjtwU&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;_বেশ কয়েক বছর সফটওয়্যার ইন্ডাস্ট্রিতে কাজ করার ফলে আমাকে অনেকেই বিভিন্ন সময় প্রশ্ন করে থাকেন যে একজন ফ্রেশ গ্রাজুয়েট বা একজন ১১/১২ সেমিস্টারের স্টুডেন্ট হিসাবে কিভাবে সফটওয়্যার কোম্পানিতে ইন্ট্রানশীপ পেতে পারেন। আমি যেহেতু Backend এ dotnet নিয়ে কাজ করি সুতরাং আমার এক্সপেরিয়েন্স থেকে বিগিনারদের জন্য dotnet এর উপর একটা গাইডলাইন শেয়ার করার চেষ্টা করলাম। এইখানে সেই সব টপিকগুলো দেওয়া আছে যে গুলো একজন ইন্ট্রান এর থেকে একটা সফটওয়্যার কোম্পানি এক্সপেক্ট করে.. &lt;br&gt;
Note: কোম্পানি টু কোম্পানি ভ্যারি করতে পারে. _&lt;/p&gt;

</description>
      <category>dotnetcore</category>
      <category>dotnet</category>
      <category>dotnetframework</category>
      <category>csharp</category>
    </item>
  </channel>
</rss>
