GitHub: https://github.com/tlangerak/Chess_Encryption
I have made a password alternative for an online bitcoin wallet (though it could be used for anything). By making the correct moves in the correct order one unlocks the correct character for the password (which automatically gets copied to the clipboard), when the wrong move is done one notices nothing but a wrong character gets into the password making it unusuable.
There are some bugs:
Move that results in a check usually give an error
More than 30 moves gives errors
very very rarely the board swaps pieves.
I started out with try to make a tangible interface for this with a raspberryPi and camera. Unfortunately I did not have engough time to achieve this and had to cancel my plans regarding this. Maybe I will continue this in the future.
See for the rest GitHub:
import processing.net.*;
import java.awt.datatransfer.*;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
ClipHelper cp = new ClipHelper(); //to copy to clipboard
boolean[] keys = new boolean[526];
boolean checkKey(String k)
{
for (int i = 0; i < keys.length; i++)
if (KeyEvent.getKeyText(i).toLowerCase().equals(k.toLowerCase())) return keys[i];
return false;
}
Client myClient; //socket with python
PImage R; //all images for pieces
PImage N;
PImage B;
PImage K;
PImage Q;
PImage P;
PImage r;
PImage n;
PImage b;
PImage k;
PImage q;
PImage p;
PImage img;
int t=0; //to draw rows/columns
int ro=-1;//^^
int co=0;//^^
String dataIn; // Data received from enige
String position[]=new String[64];//String to keep track of positions
int imageWidth; //for postion pieces
int imageHeight;//^^
int c1; //to translate mousepress to column/row
int c2;
int r1;
int r2;
String cs1="";
String cs2="";
String rs1="";
String rs2="";//^^
int toggle=0;//switch between first and second mousepress
String saved = "";//result of move eg. e2e3
String poem[]; //string of letters for password
String result[]; //actually password given (this can be different from actual password
String password[]= {
"b1c3", "g1f3", "e2e3", "f1d3", "e1g1", "d2c3", "f3e5", "h2h3", "c2d3", "d3d4", "f2f3", "f1e1" //the moves that are needed for correct password
};
String alphabet= "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; //to generate random letter
String pass ="";//the correct password
int moveTracker = 0;//to track position in array for moves
void setup() {
open("C:/Users/Administrator/Desktop/Chess_Encryption_v3/sunfish.py");//start python file with engine
size (800, 800); //set GUI
background (0);
noStroke();
smooth();
poem = split(pass, " "); //create string of letters from password
result=new String[poem.length];//setup string with correct length
myClient = new Client(this, "", 8080);//start connection with chess engine
myClient.write("connection established");//check connection
}
void draw() {
drawBoard();
dataReceive();
drawPieces();
}
void drawBoard() { // draw the board(Doh)
for (int x=0; x<= (width); x+=width/8) { //8 steps width
t++;
for (int y=0; y<= (height); y+=height/4) {//4 step height
if (t%2==1) { //alternate blackwhite with whiteblack drawing depending on row
fill(255);
rect (x, y, width/8, height/8);
fill(150);
rect (x, y+height/8, width/8, height/8);
} else {
fill(150);
rect (x, y, width/8, height/8);
fill(255);
rect (x, y+height/8, width/8, height/8);
}
}
}
t=0;
}
void drawPieces() { //draw pieces (doh)
co=0;
ro=-1;
for (int i=0; i 0) { //if available
dataIn = myClient.readString(); //read
if (dataIn.length()>75) { //if it is of correct length (not the "Not a Valid input" thingy)
for (int i=0; i=width/8*i && c1=width/8*i && r1 =width/8*i && c2 =width/8*i && r2