Saturday, September 9, 2017

Mangatha

Hi guys, i have written simple program for Mangatha using javascript. Lest play ...
You
Computer
In Out

Thursday, June 1, 2017

Deep web and Dark web

Have you guys heard the words deep web and dark web, if your answer is no, just go ahead and get surprised with some interesting facts. we are searching many things in the internet and we are thinking that we can get everything from search engines, but actually no, only 4% web content is being indexed by search engines and the remaining 96% web content can not be accessed via search engines, those web contents are called deep and dark web.

The “deep web” is the web page that exists in the internet that can not be accessed by search engines. It contains all those things as same as how our normal web application is functioning, like databases, dynamic content, some forums, sites that have never been spidered, and non of the content will be listed in search engines like google, yahoo and so on.

But "dark web" is something different than the deep web. We know many TLDs, like ".com", ".net", ".org" and so on. Have you guys seen the TLD called ".onion". Yes, dark web sites can be identified by the domain ".onion". To access the dark web pages, required specific software and specific protocol such as "Tor" browser and "Invisible Internet Project". Here, the hosted server and darken users are completely anonymous, since all the communications are happening via layered encryption. Every encrypted request/response routed through large number of intermediate server, so tracing is highly impossible, it protects the users' identity and guarantees anonymity. There are many illegal businesses and black market are running in dark web, and money is being exchanged in the form bit coins.

Guys, accessing the dark web is illegal in some of the countries, so please go though your counties cyber law before you trying anything and make sure that you aware of what you are accessing. This blog is for educational purpose only

Tuesday, May 26, 2015

Java Program - Snakes and Ladders

I have written simple program for Snakes and Ladders in java using java swing. And same i have converted into javascript as well. You can play Snakes and Ladders here. Java source code is given below, you can copy and play in your machine.

Start playing Snakes and Ladders

                   
                   
                   
                   
                   
                   
                   
                   
                   
●●                  


Computer


Java Code

package javaexperts;

import java.awt.Color;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Random;

public class SnakeAndLadder extends JFrame implements ActionListener{

JLabel lblComp = new JLabel("Computer");
JButton btnYou = new JButton("Play");
JButton newGame = new JButton("New Game");

JLabel lblCompNo = new JLabel("");
JLabel lblYouNo = new JLabel("");

JLabel lblCompPos = new JLabel("");
JLabel lblYouPos = new JLabel("");

HashMap<Integer,Integer> ladder = new HashMap<Integer,Integer>();
HashMap<Integer,Integer> snake = new HashMap<Integer,Integer>();

int youCount = 1;
int compCount = 1;

int w=15,h=15;
int x=0,y=0;

StringBuffer compList = null;
StringBuffer youList = new StringBuffer();

Random dies = new Random();

public SnakeAndLadder()  throws Throwable{
super("SnakeAndLadder");
setLayout(null);
// setLayout(new BorderLayout());
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//getContentPane().setBackground(Color.LIGHT_GRAY);
setBounds(10, 10, 700, 580);
JLabel background=new JLabel(new ImageIcon("E:\\blog\\pgms\\snakesandladders\\a.png"));
background.setBounds(0, -10, 550, 570);
add(background);

btnYou.setBounds(560, 200, 60, 30);
add(btnYou);

lblComp.setBounds(560, 250, 60, 30);
add(lblComp);

lblYouNo.setBounds(640, 200, 60, 30);
lblYouNo.setOpaque(true);
lblYouNo.setBackground(Color.BLUE);
lblYouNo.setForeground(Color.GREEN);
add(lblYouNo);

lblCompNo.setBounds(640, 250, 60, 30);
lblCompNo.setOpaque(true);
lblCompNo.setBackground(Color.RED);
lblCompNo.setForeground(Color.GREEN);
add(lblCompNo);

newGame.setBounds(580, 140, 90, 30);
add(newGame);
coinPosition(1,compCount);
lblCompPos.setBounds(x, y, w, h);
lblCompPos.setOpaque(true);
lblCompPos.setBackground(Color.RED);
background.add(lblCompPos);

coinPosition(2,youCount);
lblYouPos.setBounds(x, y, w, h);
lblYouPos.setOpaque(true);
lblYouPos.setBackground(Color.BLUE);
background.add(lblYouPos);

repaint();

ladder.put(3, 51);
ladder.put(6, 27);
ladder.put(20, 70);
ladder.put(36, 55);
ladder.put(63, 95);
ladder.put(68, 98);

snake.put(25, 5);
snake.put(34, 1);
snake.put(47, 19);
snake.put(65, 52);
snake.put(87, 57);
snake.put(91, 61);
snake.put(99, 69);

newGame.addActionListener(this);
btnYou.addActionListener(this);


}
  public static void main(String args[])  throws Throwable {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new SnakeAndLadder();
  }
  public void actionPerformed(ActionEvent e) {
 if (e.getSource() == newGame) {
 youCount = 1;
 compCount = 1;
 coinPosition(1,compCount);
 lblCompPos.setBounds(x, y, w, h);
 coinPosition(2,youCount);
 lblYouPos.setBounds(x, y, w, h);
 lblYouNo.setText("");
 lblCompNo.setText("");
 btnYou.setVisible(true);
 repaint();
 } else if (e.getSource() == btnYou) {
 compList = new StringBuffer();

 int playAgain = playDies(2);
 coinPosition(2,youCount);
 lblYouPos.setBounds(x, y, w, h);
 repaint();
 if(ladder.containsKey(youCount)) {
 youCount = ladder.get(youCount);
 } else if (snake.containsKey(youCount)){
 youCount = snake.get(youCount);
 }
 coinPosition(2,youCount);
 lblYouPos.setBounds(x, y, w, h);
 repaint();
 if(youCount == 100) {
 btnYou.setVisible(false);
 JOptionPane.showMessageDialog(this, "You win");
 } else if(playAgain == 0) {
 youList = new StringBuffer();
 do {
 playAgain = playDies(1);
 coinPosition(1,compCount);
 lblCompPos.setBounds(x, y, w, h);
 repaint();
 if(ladder.containsKey(compCount)) {
 compCount = ladder.get(compCount);
 } else if (snake.containsKey(compCount)){
 compCount = snake.get(compCount);
 }
 coinPosition(1,compCount);
 lblCompPos.setBounds(x, y, w, h);
 repaint();
 if(compCount == 100) {
 btnYou.setVisible(false);
 JOptionPane.showMessageDialog(this, "Computer win");
 break;
 }

 } while(playAgain == 1);
 }

 }
  }
 
  private int playDies(int player) {
 int playAgain = 0;
 int diesResult = 0;
 while(diesResult == 0) {
 diesResult = dies.nextInt(7);
 }
 if(player == 2){
 youList.append(String.valueOf(diesResult));
 youList.append(",");
 lblYouNo.setText(youList.toString());
 if(youCount+diesResult <= 100) {
 youCount = youCount+diesResult;
 if(diesResult == 1 || diesResult == 5 || diesResult == 6) {
 playAgain = 1;
 }
 }
 } else {
 compList.append(String.valueOf(diesResult));
 compList.append(",");
 lblCompNo.setText(compList.toString());
 if(compCount+diesResult <= 100) {
 compCount = compCount+diesResult;
 if(diesResult == 1 || diesResult == 5 || diesResult == 6) {
 playAgain = 1;
 }
 }
 }
 return playAgain;
  }
 
  private void coinPosition(int compOrYou, int count) {

 int xpos = count%10;
 int ypos = count/10;
 if(xpos == 0) {
 xpos = 10;
 ypos = ypos-1;
 }
 if(compOrYou == 1) {
 x = 5 + (xpos*55) - 55;
 } else {
 x = 25 + (xpos*55) - 55;
 }
 y = 540 - (ypos*57);
  }
}