licencing ?

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

could someone explain em a bit how licensing work ?
I've been trying to read whatever I could in the doc about that but I was
not able to decyher it ;-(
 
well, obviously my question was not clear enough !
I have no worry about the .NET framework.
I want to licence MY work. I know that the .NET framework come with some
policy to licence code and ensure 3rd party use it only if they are allowed
to.

I found a sample using the LicLicenceProvider, although I understand the
principles and the VS.NET project worked well, I was unsuccessfull in doing
one small project of my own and compile it on the command line, therefore I
still get the impression I didn't understand everything.

And I was wondering if some one could help me, by
- providing a short explanation/example ?
- send me a simple sample compilable with just a simple 'build.bat' file ?
 
hey ! you know it ! (I mean CsGL !) :-)
well it's BSD licensed and visible since a while, I have no intention to
licence it in anyway.

It's just I convince my boss to go to .NET and I want to licence our
products.
..NET has a nice licencing policy with some helpers class with different
policy at designe time (in VS.NET) and runtime, and it also work well with
no touch deployment, so I rather use it, but I'm about to understand it
thouroughly.

basically the library licence key should be embeded into the
executing/referencing assembly.
I could do it my self, but I would like to understand the licence compiler
and the other stuff before considering doing y own version.

I definitely not intend to buy when it's effectively so simple to do ...

cheers mate,
It's always a pleasure to be recognized !
where do you use CsGL ?

Lloyd

Michael Lang said:
I usually roll in my own licensing. I have a license dll file which has
various licensing properties, and knows how to encrpt and decrpt a license.
I also have a licence generator which will create the license files given
the license type and passphrase which is used as the initialization vector
(IV) in the encryption. It must be the same passphrase the application uses
as it's IV to decrpt the license file. Any application EXE or DLL i want to
license I make reference the same License dll that the generator does. It
passes in the license file and the application specific passphrase to decrpt
the license information.

It really isn't that hard, it's just a few calls to the Crptography
namespace. My entire Licensing DLL contains one class with just under 500
lines of code. The generator is a single form with just under 600 lines of
code. The Encryption/Decryption is the important part...

Why pay for licensing software, when it is so easy to make your own?
=========================================================
public class License
{
...excerpt from my class ...
#region "Encryption"
public void GenerateKey(string passPhrase)
{
//may want to change how you create your key and IV?
// They are the most important part to the secuity of your licenses.
_key = new Byte[24];
_iv = new Byte[16];

byte[] bytePhrase = Encoding.ASCII.GetBytes(passPhrase);
SHA384Managed sha384 = new SHA384Managed();
sha384.ComputeHash(bytePhrase);
byte[] result = sha384.Hash;

for( int loop=0; loop<24; loop++ ) _key[loop] = result[loop];
for( int loop=24; loop<40; loop++ ) _iv[loop-24] = result[loop];
}
/// <summary>
/// Encrypt the given value with the Rijndael algorithm.
/// </summary>
/// <param name="encryptValue">Value to encrypt</param>
/// <returns>Encrypted value. </returns>
private string Encrypt(string encryptValue)
{
CryptoStream encryptStream = null; // Stream used to encrypt
RijndaelManaged rijndael = null; // Rijndael provider
ICryptoTransform rijndaelEncrypt = null; // Encrypting object
MemoryStream memStream = new MemoryStream(); // Stream to contain data
try
{
if( encryptValue.Length > 0 )
{
// Create the crypto objects
rijndael = new RijndaelManaged();
rijndael.Key = _key;
rijndael.IV = _iv;
rijndaelEncrypt = rijndael.CreateEncryptor();
encryptStream = new CryptoStream(
memStream, rijndaelEncrypt, CryptoStreamMode.Write);

// Write the encrypted value into memory
byte[] input = new UnicodeEncoding().GetBytes(encryptValue);
encryptStream.Write(input, 0, input.Length);
encryptStream.FlushFinalBlock();

// Retrieve the encrypted value and return it
return( Convert.ToBase64String(memStream.ToArray()) );
}
else
{
return "";
}
}
catch (Exception ex)
{
throw new ApplicationException("Could not excrypt license.", ex);
}
finally
{
if( rijndael != null ) rijndael.Clear();
if( rijndaelEncrypt != null ) rijndaelEncrypt.Dispose();
if( memStream != null ) memStream.Close();
}
}
private string Decrypt(string decryptValue)
{
CryptoStream decryptStream = null; // Stream used to decrypt
RijndaelManaged rijndael = null; // Rijndael provider
ICryptoTransform rijndaelDecrypt = null; // Decrypting object
MemoryStream memStream = new MemoryStream(); // Stream to contain data
MemoryStream memCypherStream = null;
try
{
if( decryptValue.Length > 0 )
{
// Create the crypto objects
rijndael = new RijndaelManaged();
rijndael.Key = _key;
rijndael.IV = _iv;
rijndaelDecrypt = rijndael.CreateDecryptor();

memCypherStream = new
MemoryStream(Convert.FromBase64String(decryptValue));
decryptStream = new CryptoStream(memCypherStream,
rijndaelDecrypt, CryptoStreamMode.Read);

do
{
Byte[] buf = new byte[100];
int actualBytesRead = decryptStream.Read(buf,0,100);
if (0 == actualBytesRead){break;}
memStream.Write(buf,0,actualBytesRead);
}while(true);

return new UnicodeEncoding().GetString(memStream.ToArray());
}
else
{
return "";
}
}
catch (Exception ex)
{
throw new ApplicationException("Could not decrypt license.", ex);
}
finally
{
if( rijndael != null ) rijndael.Clear();
if( rijndaelDecrypt != null ) rijndaelDecrypt.Dispose();
if( memStream != null ) memStream.Close();
if( memCypherStream != null) memCypherStream.Close();
}
}
#endregion
...
}
=========================================================

By the way Lloyd, I like your C# openGL project. Is that what you are going
to license?
--
Michael Lang, MCSD
See my .NET open source projects
http://sourceforge.net/projects/dbobjecter
http://sourceforge.net/projects/genadonet

Lloyd Dupont said:
well, obviously my question was not clear enough !
I have no worry about the .NET framework.
I want to licence MY work. I know that the .NET framework come with some
policy to licence code and ensure 3rd party use it only if they are allowed
to.

I found a sample using the LicLicenceProvider, although I understand the
principles and the VS.NET project worked well, I was unsuccessfull in doing
one small project of my own and compile it on the command line,
therefore
I
still get the impression I didn't understand everything.

And I was wondering if some one could help me, by
- providing a short explanation/example ?
- send me a simple sample compilable with just a simple 'build.bat' file ?

the
.NET If
you is
no I
was
 
Back
Top