/ticketier

Securing tickets using cryptography

Primary LanguageJava

Ticketier API

Producing cryptograhically secured tickets.

Depandancies (libraries)

  1. javase-3.3.3
  2. mysql-connector-java-8.0.12
  3. zxing-core-3.3.0
  4. webcam-capture-0.3.10-dist

Classes

  1. Util
  2. Query
  3. Event
  4. Ticket
  5. User
  6. EmailBody

1. Query

Handles all database queries. Constructor expects a connection object

Query query = new Query(Connection);

Methods

Register a new user

public boolean createUser(User) throws NoSuchAlgorithmException,SQLException

User Login

public boolean authorizeUser(int id,String pass) throws NoSuchAlgorithmException,SQLException
// True -> passwords match
// False -> password mismatch

Event Creation

public boolean createEvent(Event) throws SQLException

Fetch all Events

public Event[] getEvents() throws SQLException

Fetch an event by id

public Event getEvent(int) throws SQLException

Ticket Creation

public boolean createTicket(Ticket) throws SQLException

Find Ticket by digest

public boolean getTicket(String) throws SQLException

2. Util

Utility class which performs key processes which include hashing,encryption,qr generation and scanning and interpratation. Encryption uses AES/CBC/PKCS5PADDIN Hashing uses SHA-256 algorithim

All methods in this class are static, hence can be accessed without creating an instance of the class.

Methods

Encrypt

public static String encrypt(String) throws Exception

Decrypt

public static String decrypt(String) throws Exception

Generate QR code

Generates a QR-Code png at the specified file path

  public static void generateQR(String text,String filePath) throws WriterException,IOException

Read QR code

Interprates contents of the QR-Code png contained in the specified path

  public static String readQRCode(String) throws IOException,NotFoundException

Take Picture

Takes a photo from the webcam and saves the image as ticket.png in the current working directory

 public static void takePic() throws IOException

SHA-256 Hash function

public static String sha256(String) throws NoSuchAlgorithmException

Send Email

public static void sendMail(EmailBody) throws Exception