GithubHelp home page GithubHelp logo

self-destructing-message's Introduction

Self Destructing Message

Database Set Up

  1. Install a PostgreSQL
  2. Create user and set password for it.
  3. Create Database and table using follwing script.
CREATE DATABSE self-destructing-message-db;


CREATE OR REPLACE FUNCTION generate_uid(size INT) RETURNS TEXT AS $$
DECLARE
  characters TEXT := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  bytes BYTEA := gen_random_bytes(size);
  l INT := length(characters);
  i INT := 0;
  output TEXT := '';
BEGIN
  WHILE i < size LOOP
    output := output || substr(characters, get_byte(bytes, i) % l + 1, 1);
    i := i + 1;
  END LOOP;
  RETURN output;
END;
$$ LANGUAGE plpgsql VOLATILE;

CREATE TABLE notes (
    id TEXT PRIMARY KEY DEFAULT generate_uid(16),
    name VARCHAR(50),
    message TEXT,
    password VARCHAR(64),-- SHA256 256/4=64
    email VARCHAR(50),
    generation_time TIMESTAMP,
    destruction_time TIMESTAMP,
    is_active BOOLEAN
);

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    username VARCHAR(50),
    password VARCHAR(64) -- SHA256 256/4=64
);

If you get error something like this:

org.postgresql.util.PSQLException: ERROR: function gen_random_bytes(integer) does not exist

Then check if gen_random_bytes(integer) exists or not.

select pg_get_functiondef(to_regproc('gen_random_bytes'));

If it does not exist then create it:

CREATE EXTENSION pgcrypto;

self-destructing-message's People

Contributors

khabib97 avatar

Stargazers

Amimul Ehsan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.