Is there a way i can represent a large string as an integer or something simular in size in order to indentify any changes?

I'm looking for a way to validate a long string and see if its changed, so lets say for example that  have the following string.


Now lets say that this was changed to


I'm looking for an easy way to identify if this has changed. But the key thing here is size ideally im looking for an integer style result to identify if its changed, the reason being is because in the real situation i have 10million rows, all around 5000 characters in length and this is why i cant do simple string compares i.e. not enough memory on server, so i need to store the states of each row as something smaller in size.

So to summerise is there a way i can represent a large string as an integer or something simular in size in order to indentify if any changes have taken place?

Any working examples would be greatly appreciated

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use a MD5 hash for each string

  public string GetMD5Hash(string input)
            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(input);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            string password = s.ToString();
            return password;
Dave BaldwinFixer of ProblemsCommented:
Typical file signatures are done with MD5 and SHA1.  MD5 output is 32 characters and I don't know what SHA1 is off the top of my head.
Try to convert string to byte of arrays and you can also use it to compare characters if there's changes made even if the string is in the same length.
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Asim NazirCommented:
Is this data stored in DB? Why don't you use Triggers? This way you can always check whether row exists in Auduit table and thats it.
What you say?
Webbo_1980Author Commented:
Hi asimnazir123, triggers arnt an option im afrad, has too many performance issues, thus the reason im storing everything into memory, and im not looking to change this approach at thsi stage.

Anyway i'm trying MD5 and SHA1 options as we speak and will confirm suitability shortly.

the problem with the hash is that two different strings can have the same has, so I would say that you cannot represent such a string as an integer.
Carl TawnSystems and Integration DeveloperCommented:
MD5 Hash is a little overkill if you simply want to check if the string has changed. Simply calling GetHashCode() on the string object should suffice in this scenario:
            string wibble = "Hello World";

            wibble = "HEllo World";

            wibble = "Hello World";

            wibble = "HEllo WOrld";


Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Asim NazirCommented:
One other way can be to Serialize and Deserialize strings, then you can compare them either using Deep compare at or using standard .Net library.
Webbo_1980Author Commented:
Thanks all MD5 does work, but yes gethashcode is so much simplier

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.