Google

Thursday, January 24, 2008

Earn Money

Go to the web site http://www.rentacoder.com.

There you'll find a lot of software projects(small scale to large scale) that you can bid. If you win a bid you will be offered the software project. when you start you may feel its hard to fill the application form and complete their registration procedure.(this is bit complex and long procedure). There are some specific ways to win a bid and get the software project.
This is very trusted web site and if you complete the project at deadlines you will be paid definitely.(they will pay you on regular basis depending on your deliverables to the clients.)

Be remember if you are not able to complete the project on deadlines they will consider our country and it may impact badly to the name of the Sri Lanka.

Tuesday, January 22, 2008

Two Rotation Cypher Algorithm


This is a simple encryption algorithm for strings containing only lowercase letters and spaces. You start by splitting the alphabet into two groups. The first group consists of the first firstSize letters of the alphabet, and the second consists of the remaining 26 - firstSize letters. To encrypt a character in your message, you do the following:

1. If it a space, it is kept as is.
2. If it is a letter in the first group, it is moved firstRotate letters forward in the group,
wrapping back to the start if necessary. For example, if firstSize is 6 and firstRotate is 2,
then 'A' would become 'C', and 'F' would become 'B'.
3. If it is a letter in the second group, then it is moved secondRotate letters forward in the
group, again wrapping back to the start of the group if necessary.

This is the C# implementation of the above algorithm I've developed.

public String encrypt(int firstSize, int firstRotate, int secondRotate, String originalMessage)
{
originalMessage = originalMessage.ToLower(); //converts original message to lowercase
string[] firstSet = new string[firstSize]; //splits the alphabet in to fist part
string[] secondSet = new string[26 - firstSize]; //splits the alphabet in to second part

for (int i = 0; i < c =" (char)(97" i =" 0;" c =" (char)(97" i =" 0;" character =" originalMessage[i].ToString();">= 0) //character is in the first part.
{
int index1 = Array.IndexOf(firstSet, character);
int index2 = Array.IndexOf(firstSet, character);

index1 = index1 + firstRotate;

if (index1 > (firstSize - 1))
{
index1 = firstRotate - (firstSize - index2);
}

string str = firstSet[index1];
originalMessage = originalMessage.Remove(i, 1);
originalMessage = originalMessage.Insert(i, str);
}

else if (Array.IndexOf(secondSet, character) >= 0) //character is in the second part.
{
int index1 = Array.IndexOf(secondSet, character);
int index2 = Array.IndexOf(secondSet, character);

index1 = index1 + secondRotate;
if (index1 > (25 - firstSize))
{
index1 = secondRotate - (26 - firstSize - index2);
}

string str = secondSet[index1];
originalMessage = originalMessage.Remove(i, 1);
originalMessage = originalMessage.Insert(i, str);
}
}

return originalMessage; //returns the encrypted message.
}


sample outputs :

encrypt(13, 0, 0, "this string will not change at all") returns "this string will not change at all"

encrypt(13, 7, 0, "only the letters a to m in this string change") returns "onfy tbl flttlrs h to g cn tbcs strcna jbhnal"

encrypt(17, 9, 5, "the quick brown fox jumped over the lazy dog") returns "yqn izalc kwgsf ogt bzehnm grnw yqn djvu mgp"

Friday, January 18, 2008

GNULinux - Free Software and Richard Stallman


Today we were able to attend a public speech of the Richard Stallman at SLIIT(Sri Lanka Institue of Information Technology) auditorium, Sri Lanka. He was the one who launched the GNU Project to create a free Unix-like operating system, and has been the project's lead architect and organizer. With the launch of the GNU Project he started the free software movement, and in 1985 set up the Free Software Foundation.

He talked a lot about the free software and the GNU/Linux.
This is a summary of his speech.

“Free software” is a matter of liberty, not price. To understand the concept, you should think of “free” as in “free speech”, not as in “free beer”.

Free software is a matter of the users' freedom to run, copy, distribute, study, change and improve the software. More precisely, it refers to four kinds of freedom, for the users of the software:

  • The freedom to run the program, for any purpose (freedom 0).
  • The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to improve the program, and release your improvements to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this.
I think you have done a lot of great things to the world but not properly appreciated your contribution.

Wednesday, January 16, 2008

How to call a unmanaged C++ dll from managed C#.net code

This is a sample code that you can try some really nice work.

Think you have a unmanaged C++ dll(not a .net dll) and you want to call that dll from a C#.net code. Here is the sample code to do that.

Assume this is the C++ code. In visual studio this should be within a dll project.

extern "C" __declspec(dllexport) char*__stdcall GetMessage()
{
return "this is a C++ string";
}

The output of the project should be MyAssembly.dll

and if you need to call this method from a C#, here is the code.


using System.Runtime.InteropServices;

namespace MyNameSpace
{
public class Wrapper
{
[DllImport("MyAssembly.dll")]
public static extern String GetMessage();
}
}

Now it searches for the GetMessage() method in the C++ dll.(i.e method name, method parameters, and the return type). When you do this it should match the return types of the each methods in both language.

note : here in C++ return type should be char* and it is not string.

If you call this C# method the output will be "this is a C++ string".

Try this and have some fun.