Selasa, 24 April 2012

Configuration and Installation JDK on OpenSuse 12.1

first check java by terminal with following command :

java - version

after checked it is installed jdk version 1.6 i will try update jdk with version jdk 7u3. now you can following steps so your computer or your linux can upgrade jdk with version 7 or the latest

this is steps that i use

1. Download jdk, i use jdk 7u3, select .rpm. you can download here for java latest
2. run the file with the following command : 

zypper in jdk-7u3-linux-i586.rpm

3.  after finish install we set alternatives so we can choose between jdk 7 or 6. command : 

update-alternatives --install /user/bin/java java /usr/java/jdk1.7.0_03/bin/java

4. configuration alternatives with following command

update-alternatives --config java

you must select the jdk with jdk have you installed. in here number 1 so i select number 1. then typing number 1 form keyboard and push enter

5. Test whether the jdk 7 is installed by typing in terminal : 

java -version 
  
now see : 


Good Luck : -)

 


Senin, 23 April 2012

Storing and display Image in Database

Storing Images to Database tutorial will explain how to save images to the database and how to display images that have been stored in a database
There are two ways to save images to the database:
  1. Save images to the database with the BLOB data type,
  2. Save images into a folder and record the location and image information to the database.
Which will be discussed in this tutorial is the first step, Save the image to the database with a BLOB data type.

Storing Image Into Database With Blob Data Type
There are several things that need to be done before it can save the images into a database table field of type BLOB.

Preparing the Database and Table
Create a database with a name example “gallery”. Then create a table in it with the name of “pictures” with structures like the one below:

Name Type data Information
id integer primary key, auto increment
file_name varchar(100)
mime_type varchar(50)
file_data Longblog

Or use the following SQL query:
create database gallery;
use gallery;
CREATE TABLE `pictures` (
`id` int NOT NULL AUTO_INCREMENT,
`file_name` varchar(100) NOT NULL,
`mime_type` varchar(50) NOT NULL,
`file_data` mediumblob DEFAULT NULL,
PRIMARY KEY (`id`)
);

Create Upload Form
Create a html form to upload pictures, use the script below:
<!-- file form.html-->  
<form name="form1" id="form1" method="post" action="upload.php" enctype="multipart/form-data"> 
Gambar: <input type="file" name="gambar" id="gambar" /> 
<input type="submit" name="Submit" id="Submit" value="Upload" />  
</form>

Save the file with name form.html.

Storing Images to Database

The next step is to save images to the database, php script used below to save the image to the database.
<?php $connection = mysql_connect("dbhost", "dbuser", "dbpassword"); 
 //customize to your database 
  mysql_select_db("gallery"); 
if($_FILES['gambar']['size'] > 0 && $_FILES['gambar']['error'] == 0){  
$fileName = $_FILES['gambar']['name']; $mimeType = $_FILES['gambar']['type']; 
$tmpFile = fopen($_FILES['gambar']['tmp_name'], 'rb'); 
// (fileName, mode)  
$fileData = fread($tmpFile, filesize($_FILES['gambar']['tmp_name']));  
$fileData = addslashes($fileData);  
$query = "insert into pictures set file_name='$fileName',mime_type='$mimeType', file_data='$fileData'";  
mysql_query($query) or die("Upload Gambar Gagal: ".mysql_error()); 
echo "Gambar telah disimpan"; 

?>

save the file with name upload.php


Displaying Images From Database

The final step is to display images that have been stored in a database. To display the image takes 2 files. Gambar.php file to render the image and the file gallery.php gallery to display the entire image stored in the database. Use the following script:

File picture.php

<?
php $connection = mysql_connect("dbhost", "dbuser", "dbpassword");

//customize to your database 
mysql_select_db("gallery");  
$idFile = $_GET['id'];  
$dataGambar = mysql_fetch_array(mysql_query("select * from pictures where id='$idFile'")); 
$filename = $dataGambar['file_name']; $mime_type = $dataGambar['mime_type'];  
$filedata = $dataGambar['file_data']; header("content-disposition: inline; 
filename=$filename");  
header("content-type: $mime_type"); 
header("content-length: ".strlen($filedata)); 
echo ($filedata); 
?> 

File gallery.php

<?php $connection = mysql_connect("dbhost", "dbuser", "dbpassword"); 
//customize to your database
mysql_select_db(“gallery”);
$query = “select * from pictures”;
$result = mysql_query($query);
$i=1;
echo ‘<table>’;
echo ‘<tr>’;
while($gambar = mysql_fetch_array($result)){
echo ‘<td><img src=”gambar.php?id=’.$gambar['id'].’” width=”150″ /></td>’;
if($i % 4 == 0){
echo ‘</tr><tr>’;
}
$i++;
}
echo ‘</tr>’;
echo ‘</table>’;
?>

Download Tutorial

Good Luck :-)

Minggu, 22 April 2012

Install JDK 7 on Backtrack 5

To the point please download jdk 7 (new version) from Oracle official site. In here i used jdk 7 update 3. Because i used Backtrack 32 bit. so i downloaded : jdk-7u3-linux-i586.tar.gz. 

 after you finish downloading, extract that jdk with command :

#tar xvfz jdk-7u3-linux-i586.tar.gz

after fisnish extrarc process, there will be a folder named : jdk1.7.0_03. Move the folder jdk1.7.0_03 to folder /user/lib/jvm with command :

#mv jdk1.7.0_03 /usr/lib/jvm

Following command to show anywhere JDK has been installed on our linux. For now have not seen that jdk1.7.0_03 is installed correctly

#update-alternatives --config java
There is only one alternative in link group java: /usr/lib/jvm/java-6-openjdk/jre/bin/java

That if you have just one java or jdk if you have more 2 java or jdk on your computer you will see

Selection    Path                                                           Priority   Status
————————————————————
* 0          /usr/lib/jvm/java-6-openjdk/jre/bin/java        1061      auto mode
1            /usr/bin/gij-4.4                                                   1044      manual mode
2            /usr/lib/jvm/java-6-openjdk/jre/bin/java        1061      manual mode
3            /usr/lib/jvm/java-6-sun-1.6.0.26/jre/bin/java    2         manual mode
4            /usr/lib/jvm/java-6-sun/jre/bin/java                 63        manual mode
Press enter to keep the current choice[*], or type selection number:

push enter, continue command :

#update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_03/jre/bin/java 2

then continue to configuration :

#update-alternatives --config java

you will see again :
Selection    Path                                                        Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/jdk1.7.0_03/jre/bin/java           2         manual mode

Press enter to keep the current choice[*], or type selection number:


select jdk1.7.0_03 in here number 2 so type the number 2 and push the enter

then check again jdk or java version with command :

#java -version 

you will see :

java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) Server VM (build 22.1-b02, mixed mode)


jreeeng, now you has been successful installed JDK new version
Good luck :-)

Sabtu, 21 April 2012

Cryptografi

Cryptografi is method of securing data that can be used to maintain data confidentilty, authenticity or integegrity of the data and authenticity (authentication) sender. This method is intended of important that is  retricted or confidential information send of public communication can no be know and used by unauthorized parties. criptografi is studi of learning the system in which confidentiality and authentiticity data can be guaranteed. 

Cryptografi is the science and art to keep the message to be safe.. The actors or practitioners are called cryptographers cryptography. A cryptographic algorithm (a cryptographic algorithm), called a chiper, a mathematical equation that is used for encryption and decryption. usually these two equations (for encryption and decryption) has a mathematical relationship is quite close.

The process undertaken to secure a message (called plaintext) into a hidden message (called Chipertext) is encrypted (encryption). Encryption is used to encrypt the data or information that can not be read by unauthorized people. by encrypting your data is encoded (encrypted) using a key (key). to open (decrypt) data were used also a key that can be the same as the key to encrypt (for the case of private key cryptography) or with a different key (for the case of public key cryptography).






Hash

they provide a mapping between an arbitrary length input, and a (usually) fixed length (or smaller length) output. it can be anything from a simple crc32, to a full blown cryptographic hash function such as MD5 or SHA1/2/256/512. the point is that  there's one-way mapping going on. it's always a many : mapping (meaning there will always be collisions) since every function produces a smaller output than it's capable of inputting (if you feed every possible 1mb file into MD5, you'll get a ton of collisions).





Encryption
they provide a 1:1 mapping between an arbitrary length input and output. and the are always reversible. the important thing to tnote is that it's reversible using some method. and it's always 1:1 for a given key. Now, there are multiple input : key pairs that might generate the same output (in fact there usually aare, depending on the encryption funciton). good encrypted data is indistinguishable from random noise. this is different from a good hash output which is always of a consistent format.


reference : http://stackoverflow.com

Rabu, 11 April 2012

Make Writing On The Terminal Linux OpenSuse 12.1

ok toninght i will try sharing about something linux again this is about writing on the terminal linux.

ok the first time open your terminal / konsole and install :

#sudo apt-get install fortune figlet

then type again

#vi /home/name_your_home/.bashrc

example : #vi /home/mzherri/.bashrc

then the display will be appear as follows


check at the bottom of the list and fill on the bottom with this coding

#Modification On Terminal
echo
#Figlet
figlet -f slant MzHerri

then



then save and restart your terminal and look the result



the coding italics printed it can be replaced with type writing what you want
Good Luck Guys :-)