Manan Thareja
Created March 29, 2019

P.H.I.L --- Password Handler in a Locket

Tired of having to remember all your passwords.PHIL to the rescue. Just Say "Hey PHIL" to get started.

22
P.H.I.L --- Password Handler in a Locket

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1
SparkFun RGB LED Breakout - WS2812B
SparkFun RGB LED Breakout - WS2812B
×1
Resistor 10k ohm
Resistor 10k ohm
×1
500 mah 3.7 v lipo
×1
3.3v voltage regulator
×1
Power Bank Charging Module
×1

Software apps and online services

Firebase
Google Firebase

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

PHIL Enclosure

3D model for Enclosure

Schematics

PHIL PCB

PCB Board

PHIL Schematic

Circuit Schematic

Code

PHIL.ino

C/C++
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <FastLED.h>
#define LED_PIN     5
#define NUM_LEDS    12
CRGB leds[NUM_LEDS];

// Set these to run example.
#define FIREBASE_HOST "phil-edb24.firebaseio.com"
#define FIREBASE_AUTH ""
#define WIFI_SSID "Not in range"
#define WIFI_PASSWORD "manan123"

byte com = 0; //reply from voice recognition
int group = 1;
bool Authorize; //Authorize the Client
unsigned long CurrentMillis;


void SetAll(byte red, byte green, byte blue) 
{
  for(int i = 0; i < NUM_LEDS; i++ ) 
  {
    leds[i]=CRGB(red,green,blue);
  }
  FastLED.show();
}

void FadeInOut(byte red, byte green, byte blue)
{
  float r, g, b;
      
  for(int k = 0; k < 256; k=k+1) { 
    r = (k/256.0)*red;
    g = (k/256.0)*green;
    b = (k/256.0)*blue;
    SetAll(r,g,b);
    FastLED.show();
  }
     
  for(int k = 255; k >= 0; k=k-2) {
    r = (k/256.0)*red;
    g = (k/256.0)*green;
    b = (k/256.0)*blue;
    SetAll(r,g,b);
    FastLED.show();
  }
}


void Loading()
{
  for (int i=0;i<NUM_LEDS;i++)
  {
    leds[i] = CRGB(0, 255, 255);
    leds[i-1] = CRGB(0,100,100);
    leds[i-2] = CRGB(0,50,50);
    leds[i-3] = CRGB(0,0,0);
    FastLED.show(); 
    delay(50);  
  }
  for(int j=0;j<NUM_LEDS;j++)
  {
    leds[j]= CRGB(0,0,0);
  }
}

void Not_Authorized()
{
  FadeInOut(255,0,0);
}
void Authorized()
{
  for(int i=0;i<NUM_LEDS;i++)
  {
    leds[i]=CRGB(38,252,22);
    delay(60);
    FastLED.show();
  }
  FadeInOut(38,252,22);
}

void Unauthorized()
{
  for(int i=0;i<NUM_LEDS;i++)
  {
    leds[i]=CRGB(255,0,0);
    delay(60);
    FastLED.show();
  }
  FadeInOut(255,0,0);
}


void StartListening()
{
  for(int i=0;i<NUM_LEDS;i++)
  {
    leds[i]=CRGB(137,20,232);
    delay(50);
    FastLED.show();
  }
}

void StopListening()
{ 
  SetAll(255,255,0);
  for(int i=12;i>-1;i--)
  {
    leds[i]=CRGB(0,0,0);
    delay(50);
    FastLED.show();
  }
}


void Import1() //Import Group 1
{
  group=1;
  Serial.write(0xAA);
  Serial.write(0x00);
  delay(100);
  StopListening();
  Serial.write(0xAA);
  Serial.write(0x21);
  delay(100);
  com = 0x00;
  delay(100);
}


void Import2() //Import Group 2
{
  group=2;
  Serial.write(0xAA);
  delay(100);
  Serial.write(0x00);
  delay(100);
  StartListening();
  Serial.write(0xAA);
  delay(100);
  Serial.write(0x22);
  delay(100);  
  com = 0x00;

}

void setup()
{
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  //pinMode(BuzzerPin, OUTPUT);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(50);
    Loading();
  }
  SetAll(0,0,0);
  Serial.begin(9600);
  delay(2000);
  Serial.write(0xAA);
  Serial.write(0x37);
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  delay(1000);
  Serial.write(0xAA);
  Serial.write(0x21);
  Firebase.setBool("Authorize", false);
  Firebase.setBool("P1", false);
  Firebase.setBool("P2", false);
  Firebase.setBool("P3", false);
  Firebase.setBool("P4", false);
  Firebase.setBool("P5", false);
  delay(100);
  FadeInOut(255,255,255);
  delay(100);
  SetAll(0,0,0);
}

void loop() // run over and over again
{
  Authorize = Firebase.getBool("Authorize");
  delay(100);
  while(Serial.available())
  {
    com = Serial.read();
    delay(10);
    if (group==1)
    {
      if (com==0x11)//Authorize
      {
        Firebase.setBool("Authorize", true); 
        Authorized();
        com = 0x00;    
      }

      if (com==0x12)//Unauthorize
      {
        Firebase.setBool("Authorize",  false);
        Unauthorized();
        com = 0x00;
      }

      if (com==0x13 || com==0x14 || com==0x15)//Hey Phil
      {
        if (Authorize==true) 
        {
          Import2();
        }
        else
        {
          Not_Authorized();
        }
      }
    }
    

    else if (group==2)
    {
      CurrentMillis=millis();
      while(millis()-CurrentMillis<5000UL)
      { 
        while (Serial.available())
        {
          com= Serial.read();
          if (com==0x11) //Password1
          {
            Firebase.setBool("P1", true);
            Import1();
            Firebase.setBool("P1", false);
          }
    
          if (com==0x12) //Password2
          {
            Firebase.setBool("P2", true);        
            Import1();
            Firebase.setBool("P2", false);
          }
    
          if (com==0x13) //Password3
          {
            Firebase.setBool("P3", true);
            Import1();
            Firebase.setBool("P3", false);
          }
    
          if (com==0x14) //Password4
          {
            Firebase.setBool("P4", true);
            Import1();
            Firebase.setBool("P4", false);
          }
    
          if (com==0x15) //Password5
          {
            Firebase.setBool("P5", true);
            Import1();
            Firebase.setBool("P5", false);
          }
        }
      }
      Import1();
    }
  }
}

PHIl_GUI

Python
Python File
import pyrebase 
import time
import kivy
kivy.require('1.10.0')
from pynput.keyboard import Key,Controller
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
from kivy.event import EventDispatcher
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition



Keyboard = Controller()
config = {"apiKey": "AIzaSyAuY5Z3p2fZdREOXmHgSZ9YgOKtP8ed5lI",
    "authDomain": "phil-edb24.firebaseapp.com",
    "databaseURL": "https://phil-edb24.firebaseio.com",
    "projectId": "phil-edb24",
    "storageBucket": "phil-edb24.appspot.com",
    "messagingSenderId": "1046277582393"}

FireDB = pyrebase.initialize_app(config)
DB = FireDB.database()
DB.child("P1").set(False)
DB.child("P2").set(False)
DB.child("P3").set(False)
DB.child("P4").set(False)
DB.child("P5").set(False)
DB.child("Authorize").set(False)

def Decrypt(Encrypt_Pass):
    return Encrypt_Pass

P1_Pass=Decrypt((DB.child("Password1").get()).val())
P2_Pass=Decrypt((DB.child("Password2").get()).val())
P3_Pass=Decrypt((DB.child("Password3").get()).val())
P4_Pass=Decrypt((DB.child("Password4").get()).val())
P5_Pass=Decrypt((DB.child("Password5").get()).val())



class BootScreen(Screen):
    def Switch(self):
        Authorize=(DB.child("Authorize").get()).val()
        L=self.ids["Lab"]
        L.text="Press START to Begin"
        if Authorize==True:
            self.parent.current="main"
            L.text="PRESS START TO BEGIN"
            L.color=[1,1,1,1]
        else:
            L.text="Not Authorized"
            L.color=[1,0,0,1]
    



class MainScreen(Screen):
    def Start(self):
        (self.ids["Password1"]).text=P1_Pass
        (self.ids["Password2"]).text=P2_Pass
        (self.ids["Password3"]).text=P3_Pass
        (self.ids["Password4"]).text=P4_Pass
        (self.ids["Password5"]).text=P5_Pass
    def Update(self, ID):
        Pass=self.ids[ID]
        Pass.readonly=True
        P=Pass.text
        if ID=="Password1":
            P1_Pass=P
            DB.child("Password1").set(self.Encrypt(P1_Pass))
        if ID=="Password2":
            P2_Pass=P
            DB.child("Password2").set(self.Encrypt(P2_Pass))
        if ID=="Password3":
            P3_Pass=P
            DB.child("Password3").set(self.Encrypt(P3_Pass))
        if ID=="Password4":
            P4_Pass=P
            DB.child("Password4").set(self.Encrypt(P4_Pass))
        if ID=="Password5":
            P5_Pass=P
            DB.child("Password5").set(self.Encrypt(P5_Pass))
    def Unauthorize(self):
        DB.child("Authorize").set(False)
        (self.ids["R"]).color=[1,1,1,1]
        self.parent.current="boot"
        
    def Encrypt(self,PLain_Pass):
        return PLain_Pass
    def Type(self,Password):
        for i in Password:
            Keyboard.press(i)
            Keyboard.release(i)
            time.sleep(0.1)
    def Check(self, *args):
        P1_Pass=(self.ids["Password1"]).text
        P2_Pass=(self.ids["Password2"]).text
        P3_Pass=(self.ids["Password3"]).text
        P4_Pass=(self.ids["Password4"]).text
        P5_Pass=(self.ids["Password5"]).text
        Authorize=(DB.child("Authorize").get()).val()
        P1=(DB.child("P1").get()).val()
        P2=(DB.child("P2").get()).val()
        P3=(DB.child("P3").get()).val()
        P4=(DB.child("P4").get()).val()
        P5=(DB.child("P5").get()).val()
        if Authorize==True:
            if P1==True:
                self.Type(P1_Pass)
                DB.child("P1").set(False)
            if P2==True:
                self.Type(P2_Pass)
                DB.child("P2").set(False)
            if P3==True:
                self.Type(P3_Pass)
                DB.child("P3").set(False)
            if P4==True:
                self.Type(P4_Pass)
                DB.child("P4").set(False)
            if P5==True:
                self.Type(P5_Pass)
                DB.child("P5").set(False)
        elif Authorize==False:
            (self.ids["R"]).color=[1,1,1,1]
            self.parent.current="boot"
            return False
    def Run(self):
        (self.ids["R"]).color=[0,1,0,1]
        Clock.schedule_interval(self.Check,1/30.)


class Manage(ScreenManager):
    pass

present=Builder.load_file("PHIL_GUI.kv")

class PHILApp(App):
    def build(self):
        return present

if __name__=="__main__":
    PHILApp().run()

Python GUI Kivy File

Plain text
Kivy File
#: import FadeTransition kivy.uix.screenmanager.FadeTransition


Manage:
    transition:FadeTransition()
    BootScreen:
    MainScreen:
<BootScreen>:
    name:"boot"
    BoxLayout:
        orientation:"vertical"
        Label:
            id:Lab
            text:"PRESS START TO BEGIN"
            font_size:60
        Button:
            text:"START"
            font_size:60
            on_release:root.Switch()
            

<MainScreen>:
    name:"main"
    on_pre_enter:root.Start()
    BoxLayout:
        orientation:"vertical"
        spacing:10
        padding:10
        BoxLayout:
            orientation:"horizontal"
            padding:10
            size_hint_y:None
            BoxLayout:
                orientation:"vertical"
                Label:
                    size_hint_x:0.25
                    text:"P.H.I.L"
                    font_size: 60
                    color:1,0,0,1
                Label:
                    text:"Password Handler In A Locket"
                    size_hint_x:0.6
                    font_size:30
            Button:
                id:Unauthorize
                text:"Unauthorize"
                size_hint_y:None
                size_hint_x:None
                height:40
                on_release:root.Unauthorize()
        BoxLayout:
            orientation:"horizontal"
            spacing:10
            size_hint_y:0.1
            Label:
                text:"Hackster.io"
                size_hint_x:0.1
                font_size:25

            TextInput:
                id:Password1
                text:"Password1"
                size_hint_x:0.3
                multiline:False
                password:True
                readonly:True
                on_text_validate:root.Update("Password1")
            Button:
                text:"Edit"
                size_hint_x:0.1
                on_press:Password1.readonly=False
            Button:
                text:"Show"
                size_hint_x:0.1
                on_press:Password1.password=False
                on_release:Password1.password=True
        BoxLayout:
            orientation:"horizontal"
            spacing:10
            size_hint_y:0.1
            Label:
                text:"Instagram"
                size_hint_x:0.1
                font_size:25

            TextInput:
                id:Password2
                text:"Password2"
                size_hint_x:0.3
                multiline:False
                password:True
                readonly:True
                on_text_validate:root.Update("Password2")
            Button:
                text:"Edit"
                size_hint_x:0.1
                on_press:Password2.readonly=False
            Button:
                text:"Show"
                size_hint_x:0.1
                on_press:Password2.password=False
                on_release:Password2.password=True
        BoxLayout:
            orientation:"horizontal"
            spacing:10
            size_hint_y:0.1
            Label:
                text:"Google"
                size_hint_x:0.1
                font_size:25

            TextInput:
                id:Password3
                text:"Password3"
                size_hint_x:0.3
                multiline:False
                password:True
                readonly:True
                on_text_validate:root.Update("Password3")
            Button:
                text:"Edit"
                size_hint_x:0.1
                on_press:Password3.readonly=False
            Button:
                text:"Show"
                size_hint_x:0.1
                on_press:Password3.password=False
                on_release:Password3.password=True
        BoxLayout:
            orientation:"horizontal"
            spacing:10
            size_hint_y:0.1
            Label:
                text:"Github"
                size_hint_x:0.1
                font_size:25

            TextInput:
                id:Password4
                text:"Password4"
                size_hint_x:0.3
                multiline:False
                password:True
                readonly:True
                on_text_validate:root.Update("Password4")
            Button:
                text:"Edit"
                size_hint_x:0.1
                on_press:Password4.readonly=False
            Button:
                text:"Show"
                size_hint_x:0.1
                on_press:Password4.password=False
                on_release:Password4.password=True
        BoxLayout:
            orientation:"horizontal"
            spacing:10
            size_hint_y:0.1
            Label:
                text:"Microsoft"
                size_hint_x:0.1
                font_size:25
            TextInput:
                id:Password5
                text:"Password5"
                size_hint_x:0.3
                multiline:False
                password:True
                readonly:True
                on_text_validate:root.Update("Password5")
            Button:
                text:"Edit"
                size_hint_x:0.1
                on_press:Password5.readonly=False
            Button:
                text:"Show"
                size_hint_x:0.1
                on_press:Password5.password=False
                on_release:Password5.password=True
        BoxLayout:
            orientation:"horizontal"
            padding:20
            Button:
                id:R
                text:"Run P.H.I.L"
                font_size:60
                on_press:root.Run()

Credits

Manan Thareja
4 projects • 30 followers

Comments