Hi,
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
StrongNameIdentityPermissionAttribute.
The code to create the Assembly in the first Application is as follows:
AssemblyName assembly = new AssemblyName();
assembly.Name = "Scanlib";
assembly.Version = new Version ("1.0.0.0");
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",
FileMode.Open,FileAccess.Read));
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
----------------------------------------------