Artem's blog

Mainly .NET (C#, ASP.NET) and my projects

Archives for Old clizware.net blog

Storing Information inside a Key with SKGL API

Encrypting a Key with SKGL API

Installer build into Windows

IExpress is an easy to use, free of charge, build in to Windows setup system. It consist of an easy wizard, which is also a big help to all new software developers. In order to call the program, type iexpress.exe in Run.

This is the first screen of the installer. You can either choose an existing SED file, which is basically a plaint text, or you can create a new SED file with the easy wizard.

Later on, you will be able to chose from different kinds of setups.Ether you create a setup project with an installation command, extract files only, or a CAB file that might be used by other applications.

Eventually, you will be able to specify what to display on the target machine, which files that are to be extracted, a licence agreement, dialog boxes, and more.

An advantage with IExpress is certainly the ability to use it right away – it is already installed in Windows. It is also easy-to-use and it outputs an EXE file. The output executable is also easy to follow, easy to install. Finally, it is free of charge!

A collapse-able menu

This tutorial will show you how to create a menu that can be opened and collapsed. First of all, you need to include a certain script that will do the entire thing.

// JScript source code

function showHide(objId) {
    var obj = document.getElementById(objId).style.display;

    if (obj == "inline") {
        hideObj(objId)
    }
    else {
        showObj(objId);
    }
}

function showObj(objId) {
    document.getElementById(objId).style.display = "inline";
}
function hideObj(objId) {
    document.getElementById(objId).style.display = "none";
}

Basically, it checks whether the object is collapsed or opened, and then does the oppsite; it collapses if it is open, and opens if it is collapsed. You might already now use the code above. By making a for example link (“a”), it will show and hide everytime you press it.

<a href="#" onClick="showHide('toShowOrHide');">Press to show or hide</a><br />
<div id="toShowOrHide" style="display:none">
It seems that it works!
</div>

We have a link that executes a command showHide with an argument toShowOrHide, which is, as you might see, the ID of the div. By entering the link, you will either open or collapse the div object. Remember, you might also use other tags/elements that are to be showed or hided. To see this code in work, go to http://editor.clizware.net/?id=8

Get Hash Code with Java Script

Once, I wrote about hash function that I improved. Though, that was C#. In this post I will show you how to get hash code with Java Script. (previous post)

function getStableHash(input,hashLength)
{
	/* Copyright (C) 2012 Artem Los,
	 * All rights reserved.
	 *
	 * code based on:
	 * http://blog.clizware.net/news/631
	 *
	 * originaly from: http://stackoverflow.com/questions/548158/fixed-length-numeric-hash-code-from-variable-length-string-in-c-sharp
	 */	

	 var _length = Math.pow(10,hashLength); //result in 10 numbers, if hashLength is 10
	 var hash = 0;

	 for (var j = 0; j < input.length; j++)
	 {
		 hash += input.charCodeAt(j);
		 hash += (hash << 10);
		 hash ^= (hash >> 6);
	 }

	 hash += (hash << 3);
	 hash ^= (hash >> 11);
	 hash += (hash << 15);

	 var result = ((hash % _length) + _length) % _length;//hash.mod(_length)

	 var check = parseInt(_length / result);
	 if (check > 1)
	 {
		 result *= check;
	 }

	 return result;
}

In order to calculate a hash value, you need to define two main variables. First of all, the string to calculate hash from (input), and eventually, the length of the result (hashLength). It is recommended that you set the hashLength to 8 or in some cases 10.

Please take a look at this code in work http://editor.clizware.net/?id=9

Create and Validate a Key with SKGL

SKGL is now released!

SKGL – Software licensing system is now released! The page is currently hosted at http://skgl.clizware.net/

Hash code generator

Dear Readers,

The last time I have spent on the development of SKGL API, which is a library for those of you who want to secure, protect your hard-coded .NET application. I meanwhile, I have also spent sometime on a code, (basically half an hour), that produces hash code. It is not the best way of doing it, however, so it would be a pleasure to see another version of this code. Much appreciated!

        static string twentyfiveByteHash (string s)
        {
            int amountOfBlocks = s.Length / 5;
            string[] preHash = new string[amountOfBlocks];

            if (s.Length <= 5)
            {
                //if the input string is shorter than 5, no need of blocks!
                preHash[0] = GetStableHash(s).ToString ();
            }
            else if (s.Length > 5)
            {
                //if the input is more than 5, there is a need of dividing it into blocks.
                for (int i = 0; i < amountOfBlocks-1; i++)
                {
                    preHash[i] = GetStableHash (s.Substring(i*5,5)).ToString ();
                }
                preHash[preHash.Length-1] = GetStableHash (s.Substring((preHash.Length-1) * 5, s.Length - (preHash.Length - 1) * 5)).ToString ();

            }
            return String.Join ("",preHash);
        }

        static public int GetStableHash(string s)
        {
            /*
             * modification of code from:
             * http://stackoverflow.com/questions/548158/fixed-length-numeric-hash-code-from-variable-length-string-in-c-sharp
             *
             * modified by Artem Los
             *
             */
            const int MUST_BE_LESS_OR_EQUAL_TO = 100000000;
            uint hash = 0;

            foreach (byte b in System.Text.Encoding.Unicode.GetBytes(s))
            {
                hash += b;
                hash += (hash << 10);
                hash ^= (hash >> 6);
            }

            hash += (hash << 3);
            hash ^= (hash >> 11);
            hash += (hash << 15);

            int result = (int)(hash  % MUST_BE_LESS_OR_EQUAL_TO);
            int check = MUST_BE_LESS_OR_EQUAL_TO / result;

            if (check > 1)
            {
                result *= check;
            }

            return result;
        }

Secure DotNet Applications with SKGL

SKGL – Serial Key Generating Library is an API that contains a serial key generating algorithm that helps you secure your application. This version is in BETA mode, but can still be used.  (Example is included)

SKGL might be downloaded

HTML Editor online [dev net]

In some of my previous post, I wrote about a HMTL editor available online. There are some new features:
http://editor.clizware.net/ (the editor itself)
http://editor.clizware.net/main/ (the list of all available examples)

Page 4 of 9:« First« 1 2 3 4 5 6 7 »Last »