Thursday, February 10, 2011

Counting time (another test)

Continuing from yesterday we were curious to see if java is faster than python. we know that java is slower than languages that create executable files. But python runs code by interpreting line by line. The program is the same as yesterday.
We also now that big programs may differ from the results, but we want to see just simple one's, because those that are complicated have several ways of writing.

We wrote in python:
--------------------------
#!/usr/bin/env python
import sys

a=int(sys.argv[1])
b=int(sys.argv[2])
c=a + b
print c
------------------------

Save the file as Addition.py
Make it executable:
chmod a+x Addition.py

And in java:
---------------------------------
Public class Addition
{
public static void main(String[] args)
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = a + b;
System.out.println(c);
}
}
-------------------------------

Surely python looks shorter. We run the script we mentioned yesterday:
for python:
time for ((i=1;i<=10;i++)); do
Addition.py $i $i
done

for java:
time for ((i=1;i<=10;i++)); do
java Addition $i $i
done
-----------------------------------------
Results:

Python:

real 0m0.156s
user 0m0.080s
sys 0m0.064s

Java:

real 0m0.784s
user 0m0.564s
sys 0m0.200s


On previous article we haven't explained time.
The sys time is the important thing since it is the time that the process kept cpu busy.
So
Python is faster. The difference is very well considered!!! Or was it the print out which is slow?
Let's see again:
We removed the print line of each code.

Here are the results:

real 0m0.164s
user 0m0.112s
sys 0m0.020s


real 0m0.827s
user 0m0.576s
sys 0m0.188s

Final conclusion:
Print out takes an amazing amount of time.
Python is amazingly faster than Java.

What are your experiments? Share them with us on: vaslabsco@gmail.com

Wednesday, February 9, 2011

Counting in Labs (For hardcore programmers!!!)

The below experiments were made in our labs, in order to count the time needed for a task to be completed in several ways.
We used an Ubuntu 10.10 linux machine, but it can be probably done in every linux distribution.

The target of our experiment was to watch the time needed for a simple operation to complete in several ways. Each unit was counted ten times using the script we created:

time for ((i=1; i<=10;i++)); do
java Addition $i $i
done

That way the Addition program will be executed 10 times. We divide the final output by 10 so we have a representation of the time taken to complete an operation.

We also created in java the program addition. We wanted to check first the use of functions, so we created two versions of the program, and got the results written below of each:

public class Addition
{
public static void main(String[] args)
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
System.out.println(add(a,b));
}
private static int add(int x, int y)
{
return x + y;
}
}

real 0m0.872s
user 0m0.584s
sys 0m0.228s

divide each by 10
real 0m0.087s
user 0m0.058s
sys 0m0.023s
------------------------------------------------------
public class Addition
{
public static void main(String[] args)
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);

System.out.println(a + b);
}
}

real 0m0.870s
user 0m0.584s
sys 0m0.224s


real 0m0.087s
user 0m0.058s
sys 0m0.22s

Not much a difference. But we know that printing results out costs lots of resources.
So we try again (just to be sure) with these two:

public class Addition
{
public static void main(String[] args)
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = add(a,b);
}
private static int add(int x, int y)
{
return x + y;
}
}

real 0m0.869s
user 0m0.556s
sys 0m0.208s

divide by 10
real 0m0.087s
user 0m0.0556s
sys 0m0.021s
The first thing we see is that printing in the system output cost's indeed lot of time for the system (look at the sys times). The user time also is smaller. Real time is not much of a difference, however note that small differences are still important in computers.

------------------------------------------------------------------------------------------------------
public class Addition
{
public static void main(String[] args)
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = a + b;

}
}

real 0m0.864s
user 0m0.604s
sys 0m0.192s

divide by 10
real 0m0.086s
user 0m0.060s
sys 0m0.019s
--------------------------------------------
Conclusions until now:
-In java functions take longer to output results.
-Printing out results takes lot of time

Send as your experiments and conclusions at: vaslabsco@gmail.com

Saturday, February 5, 2011

Hacking

What is a hacker?

The term hacker was once used to describe a clever programmer. Today, it’s applied to those who exploit security vulnerabilities to break into a computer system. You can think of it as electronic burglary. Hackers regularly break into both individual computers and large networks. Once they have access, they may install malicious programs, steal confidential data, or perhaps use compromised computers to distribute spam.

What is a vulnerability?

Today’s computer software is very complex, comprised of thousands of lines of code. Since software is written by humans, it’s hardly surprising that they contain programming mistakes, known as vulnerabilities. These loopholes are used by hackers to break into systems; they are also used by authors of malicious code to launch their programs automatically on your computer.


How do I protect myself from hackers?

Hackers are like electronic burglars, who use loopholes in your programs - vulnerabilities - to break into your computer system. You can protect yourself from hackers by using a firewall. A firewall program, which often comes as part of an anti-virus software package, protects a PC by detecting potential intruders and making the PC invisible to hackers.


source: kaspersky

Monday, January 31, 2011

PasswordMaker For android: The Manual!

PasswordMaker for android is out there! You can find it from android Market if you search vaslabs.security or PasswordMaker vaslabs or just passwordmaker.
A complete manual can be downloaded from there!
Don't let your accounts be hijacked!

A powerful utility from VasLabs security team! Because we know our stuff!

Password Maker for android

VasLabs announces that a new product will be available by the start of February.
Password Maker, a very useful utility for generating strong passwords, without the need of saving them will be available for android phones in about a week according to VasLabs.
The new app will have the advantage of portability and easy to use, because comparing with the Perl-command prompt version, it will have a GUI.
The new app will have the same features as the command prompt one:
-generating strong passwords
-different password for each mobile phone
-managing passwords by reason you want them
-should remember only one password

Tuesday, January 25, 2011

Make an exclusive-OR Gate by using NAND's

A NAND B = ¬(AΛB)
A XOR B = ¬AΛB + AΛ¬B

We have to make XOR equation has the form of NAND.
We will use De Morgan's Theorem: ¬AV¬B = ¬(AΛB)
¬AΛ¬B = ¬(AVB)

¬AΛB V AΛ¬B = ¬ (AV¬B) V ¬ (¬AVB)
= ¬¬ ( ¬ (AV¬B) V ¬ (¬AVB) )
= ¬ ( (AV¬B) Λ (¬AVB) )
= ¬ ( (AΛB) V (¬AΛ¬Β) )
= ¬(AΛB) Λ ¬(¬AΛ¬Β)
= ¬(AΛB) Λ (AVΒ)
= (¬(AΛB)ΛΑ) V (¬(AΛB)ΛB)
= ¬¬((¬(AΛB)ΛΑ) V (¬(AΛB)ΛB))
= ¬( ¬ ( ¬(AΛB) Λ Α ) Λ ¬( ¬(AΛB) Λ B ) )



Now we have a NAND "¬(AΛB)" connected to a NAND with A as second
input, connected to a NAND that has one input from the first NAND and B, and both are connected to a NAND.
Note: V = OR, ¬ = NOT, Λ = AND


Monday, January 3, 2011

Joker, extra5, Keno and Lotto!


Do you have android? Do you like joker, kino, lotto and other such games?Do you want to find numbers, probabilities, costs and combination in one second? This is for you!