468,505 Members | 1,599 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

Regex Assembly security


I'm now nearing the completion of my first c# development. I have two applications. The first is
a simple database app that uses an Access database to store Regex strings along with a
description and various flags. This application has an export facility that compiles the Regexs
to an assembly and produces a flat file containing the descriptions and flag settings.

The second application, uses the Regex assembly and flat file to allow grouped Regex's to be ran
against the contents of files.

Everything is working correctly in the applications, however I would like to secure the Regex
assembly to prevent the underlying Regex's being easily stolen / used by a third party.

Currently, the Regex strings can be easily viewed using ILDASM. Also, how can I secure the
assembly from being used by a thirdparty?

I found this article: http://www.codeguru.com/Csharp/Cshar...cle.php/c8329/
but that assumes that I have the access to the Classes in the assembly to be able to use the

The code to create the Assembly in the first Application is as follows:

AssemblyName assembly = new AssemblyName();
assembly.Name = "Scanlib";
assembly.Version = new Version ("");
assembly.CultureInfo = new CultureInfo ("en-GB");
assembly.HashAlgorithm = AssemblyHashAlgorithm.SHA1;
assembly.CodeBase = String.Concat ("file:///", Directory.GetCurrentDirectory());
assembly.VersionCompatibility = AssemblyVersionCompatibility.SameProcess;
assembly.Flags = AssemblyNameFlags.PublicKey;
assembly.KeyPair = new StrongNameKeyPair (File.Open ("PublicPrivateKeyFile.snk",

Regex.CompileToAssembly( myRegexs.ToArray() , assembly );
The second Application, loads in the Assembly and then uses Reflection to store the Regexs
types for later use.

myassembly = Assembly.LoadFrom ("MyRegexAssembly.dll");
string strlibName = "MyRegex.Regex" + uniqueKey;
mytype = myassembly.GetType ( strlibName );

Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
Nov 17 '05 #1
0 1055

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Thomas Christmann | last post: by
3 posts views Thread by Daylor | last post: by
2 posts views Thread by John Grandy | last post: by
8 posts views Thread by Richard Lionheart | last post: by
2 posts views Thread by Martin Hart | last post: by
14 posts views Thread by ohmmega | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.