0% found this document useful (0 votes)
133 views5 pages

Adminmainfakeproductdetection

The document outlines a Python application using Tkinter for product authentication and counterfeit elimination through blockchain technology. It allows users to add products, generate QR codes, and retrieve product information based on a unique product ID. The application also features a graphical interface with options to save product data and display relevant details from the blockchain.

Uploaded by

nikhil.goo20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views5 pages

Adminmainfakeproductdetection

The document outlines a Python application using Tkinter for product authentication and counterfeit elimination through blockchain technology. It allows users to add products, generate QR codes, and retrieve product information based on a unique product ID. The application also features a graphical interface with options to save product data and display relevant details from the blockchain.

Uploaded by

nikhil.goo20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

from tkinter import messagebox

from tkinter import *


from tkinter import simpledialog
import tkinter
from tkinter import filedialog
from [Link] import askopenfilename
from Block import *
from Blockchain import *
from hashlib import sha256
import os
import datetime
import webbrowser
import qrcode
import random
import cv2
import sys
from PIL import ImageTk, Image
import [Link]
import imageio
import threading

main = [Link]()
[Link]("Authentication of products-Counterfeit Elimination Using BlockChain")
[Link]('-fullscreen', True)
#[Link]('1300x1200')

video_name = "bg\\[Link]" #This is your video file path


video = imageio.get_reader(video_name)
def stream(label):
for image in video.iter_data():
frame_image = [Link]([Link](image))
[Link](image=frame_image)
[Link] = frame_image

my_label = [Link](main)
my_label.pack()
thread = [Link](target=stream, args=(my_label,))
[Link] = 1
[Link]()

global filename

blockchain = Blockchain()
if [Link]('blockchain_contract.txt'):
with open('blockchain_contract.txt', 'rb') as fileinput:
blockchain = [Link](fileinput)
[Link]()

def addProduct():
global filename
[Link]('1.0', END)
#filename = askopenfilename(initialdir = "original_barcodes")
#with open(filename,"rb") as f:
# bytes = [Link]()
#[Link]()
pid = [Link]()
name = [Link]()
user = [Link]()
address = [Link]()
neer=hex([Link](128))
bytes=[Link]('utf-8')
digital_signature = sha256(bytes).hexdigest();

global QRimg
logo = [Link]('bg\\[Link]')
basewidth = 100
wpercent = (basewidth/float([Link][0]))
hsize = int((float([Link][1])*float(wpercent)))
logo = [Link]((basewidth, hsize), [Link])
QRcode = [Link](error_correction=[Link].ERROR_CORRECT_H)
QRcode.add_data(digital_signature)
[Link](fit=True)
QRimg = QRcode.make_image().convert('RGB')
pos = (([Link][0] - [Link][0]) // 2, ([Link][1] - [Link][1]) //
2)
[Link](logo, pos)
[Link]('original_barcodes'+'\\'+str(pid)+'[Link]')

if len(pid) > 0 and len(name) > 0 and len(user) > 0 and len(address) > 0:
current_time = [Link]()
data = pid+"#"+name+"#"+user+"#"+address+"#"+str(current_time)
+"#"+digital_signature
blockchain.add_new_transaction(data)
hash = [Link]()
b = [Link][len([Link])-1]
[Link](END,"Blockchain Previous Hash : "+str(b.previous_hash)
+"\n")
[Link](END,"Block No : "+str([Link])+"\n")
[Link](END,"Product Qr-code no : "+str(digital_signature)
+"\n")

blockchain.save_object(blockchain,'blockchain_contract.txt')
img2= [Link]('original_barcodes'+'\\'+str(pid)+'[Link]')
load=[Link]((200,200))
render = [Link](load)
img = Label(main, image=render)
[Link](x=140, y=500)

[Link](0, 'end')
[Link](0, 'end')
[Link](0, 'end')
[Link](0, 'end')
[Link]("QR Code Generator", "QR Code is saved successfully!")

else:
[Link](END,"Please enter all details")

def searchProduct():
[Link]('1.0', END)
pid = [Link]()

flag = True
if len(pid) > 0:
for i in range(len([Link])):
if i > 0:
b = [Link][i]
data = [Link][0]
arr = [Link]("#")
if arr[0] == pid:
global QRimg
logo = [Link]('bg\\[Link]')
basewidth = 100
wpercent = (basewidth/float([Link][0]))
hsize = int((float([Link][1])*float(wpercent)))
logo = [Link]((basewidth, hsize), [Link])
#logo = [Link]((basewidth, hsize),
[Link])
QRcode =
[Link](error_correction=[Link].ERROR_CORRECT_H)
QRcode.add_data(arr[5])
[Link](fit=True)
QRimg = QRcode.make_image().convert('RGB')
pos = (([Link][0] - [Link][0]) // 2, ([Link][1] -
[Link][1]) // 2)
[Link](logo, pos)
[Link]('original_barcodes'+'\\'+str(pid)+'[Link]')
output = ''
[Link](END,"Product Details extracted from Blockchain
using Product ID : "+pid+"\n\n")
[Link](END,"Product ID :
"+arr[0]+"\n")
[Link](END,"Product Name :
"+arr[1]+"\n")
[Link](END,"Company/User Details :
"+arr[2]+"\n")
[Link](END,"Address Details :
"+arr[3]+"\n")
#[Link](END,"hash code
: "+arr[4]+"\n")
[Link](END,"Product Registered Date & Time :
"+arr[4]+"\n")
[Link](END,"Product Qr Code :
"+arr[5]+"\n")

output='<html><body><table border=1>'
output += '<tr><th>Block No</th><th>Product ID</th><th>Product
Name</th><th>Company/User Details</th><th>Address Details</th><th>Scan Date &
Time</th><th>Product Qr code</th></tr>'
output += '<tr><td>' + str(i) + '</td><td>' + arr[0] +
'</td><td>' + arr[1] + '</td><td>' + arr[2] + '</td><td>' + arr[3] + '</td><td>' +
arr[4] + '</td><td>' + arr[5] + '</td></tr>'
f = open("[Link]", "w")
[Link](output)
[Link]()
#[Link]("[Link]",new=1)
flag = False
img2= [Link]('original_barcodes'+'\\'+str(pid)
+'[Link]')
load=[Link]((200,200))
render = [Link](load)
img = Label(main, image=render)
[Link](x=140, y=500)
#[Link]("", "Retrieve product QR-code!")

break
if flag:
[Link](END,"Given product id does not exists")

main.wm_attributes('-transparentcolor', '#ab23ff')
font = ('times', 30, 'bold')
title = Label(main, text='Authentication of products-Counterfeit Elimination Using
BlockChain')
[Link](bg="green",fg='black')
[Link](font=font)
[Link](height=3, width=50)
[Link](x=170,y=5)

font1 = ('times', 13, 'bold')

l1 = Label(main, text='Product ID :')


[Link](font=font1)
[Link](x=280,y=200)

tf1 = Entry(main,width=80)
[Link](font=font1)
[Link](x=470,y=200)

l2 = Label(main, text='Product Name :')


[Link](font=font1)
[Link](x=280,y=250)

tf2 = Entry(main,width=80)
[Link](font=font1)
[Link](x=470,y=250)

l3 = Label(main, text='Company/User Details :')


[Link](font=font1)
[Link](x=280,y=300)

tf3 = Entry(main,width=80)
[Link](font=font1)
[Link](x=470,y=300)

l4 = Label(main, text='Address Details :')


[Link](font=font1)
[Link](x=280,y=350)

tf4 = Entry(main,width=80)
[Link](font=font1)
[Link](x=470,y=350)

def run13():
[Link]()
import Main

#[Link]('[Link]',)

scanButton = Button(main, text="Home Page",bg="dark orange", command=run13)


[Link](x=1400,y=200)
[Link](font=font1)

saveButton = Button(main, text="Save Product with Blockchain Entry",


command=addProduct)
[Link](x=420,y=400)
[Link](font=font1)

searchButton = Button(main, text="Retrieve Product Data", command=searchProduct)


[Link](x=850,y=400)
[Link](font=font1)

font1 = ('times', 13, 'bold')


text=Text(main,height=15,width=100)
scroll=Scrollbar(text)
[Link](yscrollcommand=[Link])
[Link](x=400,y=450)
[Link](font=font1)

[Link](bg='cornflower blue')
[Link]()

You might also like