QT and Linking Other Libraries

I started QT and trying to write some small programs. In one program, I wanted to send mail. Found a code how to send mail in C++ (uses winsock library, not QT’s) and integrated it to my program. But how, I gives some bunch of errors. They were linking errors.

... /mailer.cpp:17: undefined reference to `WSAStartup@8'
...

Then a little research helped to me: This link.

Open your project file (<projectname>.pro):

and add the line:

LIBS += < WHERE-YOUR-LIBRARY-FILE-IS-LOCATED >

If your library is located in [QTDIR]\mingw\lib directory, you can just add the name of it (without its filename extension: .a):

LIBS += libwsock32

If you are developing in linux, the default library directory(or one of the library directories) might be /usr/lib.

Linux Process Invisibility

Hello again, we have given a project in System Programming course. It was expected you to alter the kernel code for process invisibility, when you ps, process can not be seen in the output, if process invisibility flag is “1”.

The project was modifying the linux kernel for process invisibility, writing a system call for setting the invisibility flag and writing a user-space program.

Project was developed at Xubuntu 9.10 guest on Windows 7 host. Eclipse (with CDT and Remote System Explorer plugins) was the development IDE. Putty SSH client was also used for executing commands and “command copy/paste” availability. VirtualBox was the virtual machine supervisor.

ATTENTION: This code is experimental. If you try, it will be your own responsibility.
Continue reading Linux Process Invisibility

SHA512 hashing on Java

Hello! For my school project, I had been tought of crypting passwords of users. Due to the fact that, SHA1 algorithm has security problems (link) , I have decided using a SHA2. SHA2 has 3 variants: SHA256, SHA384 and SHA512. While I was searching how to implement SHA2 on Java,  I have found this link.

For SHA512 that code works:


import java.security.*;

public class cryptotest {
    public static void main(String[] args) throws NoSuchAlgorithmException {
        MessageDigest md;
        String message = "password";
        try {
            md= MessageDigest.getInstance("SHA-512");

            md.update(message.getBytes());
            byte[] mb = md.digest();
            String out = "";
            for (int i = 0; i < mb.length; i++) {
                byte temp = mb[i];
                String s = Integer.toHexString(new Byte(temp));
                while (s.length() < 2) {
                    s = "0" + s;
                }
                s = s.substring(s.length() - 2);
                out += s;
            }
            System.out.println(out.length());
            System.out.println("CRYPTO: " + out);

        } catch (NoSuchAlgorithmException e) {
            System.out.println("ERROR: " + e.getMessage());
        }
    }
}

If you want to hash password with SHA256, you can change the line:

md= MessageDigest.getInstance("SHA-512");

to

md= MessageDigest.getInstance("SHA-256");

For others:

md= MessageDigest.getInstance("MD5");
md= MessageDigest.getInstance("SHA");
md= MessageDigest.getInstance("SHA-1");
md= MessageDigest.getInstance("SHA-384");

KDE4 and Dual Monitors

KDE4 has brought a new concept to desktop by Plasma. However, it was not considered that Plasma should work on more than one monitors. It has rumours that KDE 4.2 has a fix for multi-monitoring, this fix is not working. While I was searching for the problem, I found an alternative solution to monitoring on KDE-Forums (It redirects to Gentoo-Wiki).

  1. Backup your xorg.conf file (/etc/X11/xorg.conf ).
    cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
  2. Configure your xorg.conf file for dual monitors. I don’t now how ATI is configured, but for NVIDIA you can use nvidia-settings program. You must configure both screen as seperate screen. Your main screen’s height should be greater than second’s and Xinerama should be disabled.  Then click “Save to X Configuration File” and save it.
    nvidia-settings
  3. Install ICEWM by your default repository manager.
    For Gentoo:

    emerge -av icewm
  4. Restart your Xorg server by
    Ctrl+Alt+Backspace.
  5. Open a console then write:
    DISPLAY=":0.1" icewm
  6. If you want to work with “icewm” every start of your computer:
    echo 'DISPLAY=":0.1" icewm &' > ~/YOUR_KDE_FOLDER/Autostart/icewmstart.sh

    If folder name is “.kde”:

    echo 'DISPLAY=":0.1" icewm &' > ~/.kde/Autostart/icewmstart.sh

And then my dual monitors 🙂

dualmonitors

If your second monitor left of the main monitor you can configure xorg.conf file like this:
Find the line:

    Screen      1  "Screen1" RightOf "Screen0"

Then change to:

    Screen      1  "Screen1" LeftOf "Screen0"