Alex Rivera | Logout

Simple obfuscation of string in .NET?

Asked 2012-10-23T08:03:42.573
20

I need to send a string of about 30 chars over the internet which will probably end up as an ID in a another company's database.

While the string itself will not be identifying, I would still like it not to be recognisable in any way.

What is the easiest way to obfuscate such a string in .NET, so that it can be easily reversed when necessary?

Edit
Report

1 Answer

11

How about:

    Convert.ToBase64String(Encoding.UTF8.GetBytes(myString));

and its converse:

    Encoding.UTF8.GetString(Convert.FromBase64String(myObfuscatedString));

as long as you don't mind an increase in the length of your string

answered 2012-10-23T08:27:27.373

Your Answer