Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a .NET user control in C# and it has lots of exception messages(literals). If I extract these literals into a resource file and let these message stay the same. does this extraction help me to obfuscate my application?

Here is a small demo to explain what I said:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestResource
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int text1 = Convert.ToInt32(textBox1.Text);
            int text2 = Convert.ToInt32(textBox2.Text);
            int result = text1+text2;

            if (result <= 100)
                MessageBox.Show(result.ToString());
            else
            {
                throw new ArgumentOutOfRangeException("exceeds the maximum upper bound 100");
            }

        }
    }
}


now I extract this literal "exceeds the maximum upper bound 100" into a resource file and the following code as this:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestResource
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int text1 = Convert.ToInt32(textBox1.Text);
            int text2 = Convert.ToInt32(textBox2.Text);
            int result = text1+text2;

            if (result <= 100)
                MessageBox.Show(result.ToString());
            else
            {
                throw new ArgumentOutOfRangeException(Resource.English.Exceeds100Message);
            }

        }
    }
}


After I compiled this into an executable then run obfuscator software .
because this button click method is private, it will be obfuscated.
Does this "Resource.English.Exceeds100Message" variable help obfuscation?
Posted
Updated 14-Feb-15 13:38pm
v4
Comments
BillWoodruff 14-Feb-15 18:30pm    
I think you need to say more about what exactly "obfuscation" refers to here. Are you referring to the end-result of running "obfuscation software" like DotFuscator on your .NET assemblies ?
Southmountain 14-Feb-15 19:33pm    
Yes. it is the case.

1 solution

"Does it help obfuscation"?

No. Your string literals will still be in clear text in the executable.
 
Share this answer
 
Comments
Southmountain 14-Feb-15 21:06pm    
string is fine, how about the variable name Exceeds100Message?
Dave Kreskowiak 14-Feb-15 21:49pm    
Names like that usually get obfuscated, depending on the tool you're using.
BillWoodruff 14-Feb-15 21:54pm    
Hi Dave, fyi: some .NET obfuscators, like Cryto Obfuscator (commercial, 3rd. party), claim they can encrypt/scramble contents of resources. Note that I have not purchased/used Crypto Obfuscator, I just remember this fact from reading their product description when I took a brief tour of the various obfuscators available for .NET about a year ago.
Dave Kreskowiak 14-Feb-15 21:57pm    
It's possible. I've only seen the free ones and they didn't touch the resources. I really have no need for an obfuscator.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900