def Authentication(self, l): count = 0 myCode = QR(filename=u"/home/pi/Desktop/image.png") myCode.decode() n = myCode.data_to_string() print n
def read_qrcode_and_open_the_web(): print "\n\nDecoding QR Code ..." qr = QR(filename = "qr-code.png") qr.decode() print "Decoded data: " print qr.data return qr.data
def extract(self): pnr=raw_input("Enter PNR no.:\t") # Python 2.x program to Scan and Read a QR code my_QR = QR(filename = pnr+".png") # decodes the QR code and returns True if successful my_QR.decode() # prints the data print my_QR.data
def qr_read(request): data_value=json.loads(request.body) print(data_value) my_QR = QR(filename = "/opt/lampp/htdocs/qrcodes/"+data_value['name']) # decodes the QR code and returns True if successful my_QR.decode() # prints the data return HttpResponse(my_QR.data)
def read(): # Python 2.x program to Scan and Read a QR code my_QR = QR(filename="/home/jumana/Desktop/second.png") # decodes the QR code and returns True if successful my_QR.decode() val = my_QR.data # prints the data print val
def Authentication(self,l): count =0 myCode=QR(filename=u"/home/pi/Desktop/image.png") myCode.decode() n=myCode.data_to_string() for a in l: for y in a: x=y.encode("utf-8") if x == n[3:]: count+=1 return count
def check_qr(file): qr = QR() if qr.decode(file): print qr.data return True return False
def takein(self): self.turn_red() ''' capture image''' os.system('fswebcam -r 1024x786 --jpeg 500 qw.jpeg') '''sleep to recover image''' time.sleep(5) '''extract qrcode''' myCode = QR(filename="/home/pi/Desktop/project/ikart/qw.jpeg") if myCode.decode(): print myCode.data print myCode.data_type print myCode.data_to_string() '''send product''' self.send_product() '''update xml ''' self.update_xml() '''display details on lED''' self.displaydetails()
def scanadd(name): myCode = QR(filename=name) if myCode.decode(): if myCode.data_type == "text": print "worked" retval="" add = False start = True for x in myCode.data: if x in "13" and start: add = True start = False retval+=x elif add and x in "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ": retval+=x else: add=False print "raw",myCode.data return retval #aystit(retval, amt) else: print "That isn't text you tricky trickster" else: print "I can't decode that. Sorry."
def decodeFile(self, fn=None): if not fn: fn = unicode(QtGui.QFileDialog.getOpenFileName( self, u'Open QRCode', filter=u'Images (*.png *.jpg);; All Files (*.*)' ) ) if os.path.isfile(fn): qr = QR(filename=fn) if qr.decode(): self.showInfo(qr) else: QtGui.QMessageBox.information( self, u'Decode File', u'No QRCode could be found in file: <b>%s</b>.' % fn ) else: QtGui.QMessageBox.information( self, u"Decode from file", u"The file <b>%s</b> doesn't exist." % os.path.abspath(fn), QtGui.QMessageBox.Ok )
def decode_qr(img_name): qr = QR() if qr.decode(img_name): return qr.data.split(' ')[-1].encode('utf-8') else: return False
def decodeKey(file): decCode = QR(filename=file) if decCode.decode(): key = decCode.data int_key = [] for b in key.split('/'): int_key.append(int(b)) return int_key
def decodeKey(file): decCode = QR(filename=file) if decCode.decode(): key = decCode.data int_key = [] for b in key.split('/'): int_key.append(int(b)) return int_key
def decode_image(filename="default.png"): """default.png is a sample image. for more qr code images, see http://qrcode.kaywa.com/""" my_code = QR(filename=os.path.dirname(os.path.abspath(__file__)) + "/" + filename) if my_code.decode(): print my_code.data return my_code.data else: return None
def decodeQRCode(fileName, path=""): """expects fileName is .jpg""" myCode = QR(filename = path + fileName) if myCode.decode(): print "decoderen qr gelukt" return myCode.data else: print "decoderen qr gefaald" return False
def decodeAES(key, file): if isinstance(key, str): int_key = hexToKey(key) elif isinstance(key, list): int_key = key[:] AESqr = QR(filename=file) if AESqr.decode(): plaintext = dAES.decrypt(AESqr.data, int_key) return plaintext
def decodeAES(key, file): if isinstance(key, str): int_key = hexToKey(key) elif isinstance(key, list): int_key = key[:] AESqr = QR(filename=file) if AESqr.decode(): plaintext = dAES.decrypt(AESqr.data, int_key) return plaintext
def uploaded(file): from qrtools import QR myCode = QR(filename=file) if myCode.decode(): print myCode.data g.db.execute('insert into vehicle (p_num,dataa) values(?,?)',[session.get('id'),myCode.data]) g.db.commit() return redirect(url_for('landing')) return 'Something went wrong'
def get_qr_code(image_filename): """ Return True if the given image is a front page (based on a QR code) or false otherwise. The QR code must contain FRONT_PAGE_CODE to indicate that the page is a front page. """ scanner = QR(filename=image_filename) if scanner.decode(): data = scanner.data return data else: return None
def get_qr_code(image_filename): """ Return True if the given image is a front page (based on a QR code) or false otherwise. The QR code must contain FRONT_PAGE_CODE to indicate that the page is a front page. """ scanner = QR(filename=image_filename) if scanner.decode(): data = scanner.data return data else: return None
def main(): if len(argv) < 2: print 'Format: enc.py <image>' return qr = QR() qr.decode(argv[1]) TEXT = qr.data MESSAGE = TEXT[:100].strip('*\r\n') SIGN = TEXT[100:500].strip('*\r\n').decode('hex') ID = TEXT[500:].strip('*\r\n') publickey = PublicKey.load_pkcs1(open('DB/' + ID + '.pub').read()) if verify(MESSAGE, SIGN, publickey): print MESSAGE else: print 'VERIFICATION FAILED!'
def takein(self): self.update_xml('') return self.turn_red() '''try: find=os.remove("/home/pi/Desktop/project/ikart/qw.jpeg") except OSError: pass''' ''' capture image''' try : '''fswebcam -d /dev/video0 -S 2 -s brightness=60% -s Contrast=15% -s Gamma=50% -p YUYV -r 1280x720 --jpeg 80 -s Sharpness=40% -s Saturation=15% --title "New Zealand - Wellington - Tawa" $DIR/$filename''' os.system('fswebcam -r 100x100 --jpeg 1000 qw.jpeg') except IOError: time.sleep(1) os.system('fswebcam -r 300x300 --jpeg 500 kqrcode.jpeg') '''sleep to recover image''' time.sleep(4) '''extract qrcode''' try : myCode = QR(filename="/home/pi/Desktop/project/ikart/kqrcode.jpeg") if myCode.decode(): print myCode.data print myCode.data_type print myCode.data_to_string() m=myCode.data_to_string() print (m) '''update xml ''' self.update_xml(m) '''display details on lED''' self.displaydetails() except IOError as e: print(e,'sfhgdfhsdhdsh',myCode,str(myCode)) return 0 pass
def get_qr_code(image_name): scans_dir = u"scans/" codes_dir = u"codes/" input_scan_path = scans_dir + image_name + u"-result.jpg" qr_code = QR(filename=input_scan_path) if qr_code.decode(): return qr_code.data else: return None
def qrimg(lines,filename): lines = unicode(lines, "utf-8") img=Image.new("RGBA", (380,380),(255,255,255)) draw = ImageDraw.Draw(img) y_text =8 for line in lines.splitlines(): width, height = font.getsize(line) draw.text((10,y_text),line,(0,0,0), font=font) y_text +=height draw = ImageDraw.Draw(img) #img = img.resize((380,420)) img.save(filename) thedata = QR(filename=filename) if thedata.decode(): return thedata.data else: return "Error: " + filename + " "
def decodeFile(self, fn=None): if not fn: fn = unicode( QtGui.QFileDialog.getOpenFileName( self, self.trUtf8("Open QRCode"), filter=self.trUtf8("Images (*.png *.jpg);; All Files (*.*)") ) ) if os.path.isfile(fn): qr = QR(filename=fn) if qr.decode(): self.showInfo(qr) else: QtGui.QMessageBox.information( self, self.trUtf8("Decode File"), unicode(self.trUtf8("No QRCode could be found in file: <b>%s</b>.")) % fn, )
def qrimg(lines, filename): lines = unicode(lines, "utf-8") img = Image.new("RGBA", (380, 380), (255, 255, 255)) draw = ImageDraw.Draw(img) y_text = 8 for line in lines.splitlines(): width, height = font.getsize(line) draw.text((10, y_text), line, (0, 0, 0), font=font) y_text += height draw = ImageDraw.Draw(img) #img = img.resize((380,420)) img.save(filename) thedata = QR(filename=filename) if thedata.decode(): return thedata.data else: return "Error: " + filename + " "
def solve(filename): (_, tmp) = tempfile.mkstemp() while True: qrpic = QR(margin_size=0, filename=filename) if qrpic.decode(): data = qrpic.data if len(data) < 32: print(data) break qr_data_to_qr(data, tmp) filename = tmp else: print('Unable to solve', file=sys.stderr) break os.unlink(tmp)
def btnTakePhotoClick(self, event): qr = QR() i = 0 while qr.data == "NULL": #while i == 0: _filename = '/home/pi/cpi/camera' + str(i) + '.jpg' camera = picamera.PiCamera() camera.resolution = (300, 300) camera.capture(_filename) print "gecaptured: " + _filename z = qr.decode(_filename) print z bm = wx.Image(_filename, wx.BITMAP_TYPE_ANY).ConvertToBitmap() #bitmap = wx.Bitmap(QR_IMAGE_FILE) #bitmap = self.scale_bitmap(bitmap, 300, 300) #control = wx.StaticBitmap(self, -1, bitmap) #control.SetPosition((10, 10)) self.imgQROutgoing.SetBitmap(bm) self.textImageWhatToDo.Label="Message: " + qr.data #self.Refresh() self.Update() print "refreshed" #im = Image.open('/home/pi/cpi/camera' + str(i) + '.jpg') #pho = ImageTk.PhotoImage(im) #label = Label(image = pho) #label.image = pho #label.pack() ##root.update() ###frame.update() #self.ph.image = pho print "bild camera" + str(i) + ".jpg angezeigt" time.sleep(1) camera.close() #qr.destroy() i = i + 1 print "i ist jetzt: " + str(i) print "--------------------------------------"
def decodeFile(self, fn=None): if not fn: fn = unicode( QtGui.QFileDialog.getOpenFileName( self, self.trUtf8('Open QRCode'), filter=self.trUtf8( 'Images (*.png *.jpg);; All Files (*.*)'))) if os.path.isfile(fn): qr = QR(filename=fn) if qr.decode(): self.showInfo(qr) else: QtGui.QMessageBox.information( self, self.trUtf8('Decode File'), unicode( self.trUtf8( 'No QRCode could be found in file: <b>%s</b>.')) % fn)
def decodeFile(self, fn=None): if not fn: fn = QtWidgets.QFileDialog.getOpenFileName( self, 'Open QRCode', filter='Images (*.png *.jpg);; All Files (*.*)') fname = fn[0] else: fname = fn if os.path.isfile(fname): qr = QR(filename=fname) if qr.decode(): self.showInfo(qr) else: QtWidgets.QMessageBox.information( self, 'Decode File', unicode('No QRCode could be found in file: <b>%s</b>.') % fname)
def decodeFile(self, fn=None): if not fn: fn = unicode( QtGui.QFileDialog.getOpenFileName( self, u'Open QRCode', filter=u'Images (*.png *.jpg);; All Files (*.*)')) if os.path.isfile(fn): qr = QR(filename=fn) if qr.decode(): self.showInfo(qr) else: QtGui.QMessageBox.information( self, u'Decode File', u'No QRCode could be found in file: <b>%s</b>.' % fn) else: QtGui.QMessageBox.information( self, u"Decode from file", u"The file <b>%s</b> doesn't exist." % os.path.abspath(fn), QtGui.QMessageBox.Ok)
def readqr(data): filename = "%s%s.bmp" % (imgpath, str(uuid.uuid4())) ##qr mappings cmap = {'0': (255, 255, 255), '1': (0, 0, 0)} ## clean up the data length = len(data.split("\n")) data = data.replace("\n", "") ##build image rawdata = [cmap[letter] for letter in data] img = Image.new('RGB', (length, len(data) // length), "white") img.putdata(rawdata) img.save(filename, 'BMP') ##decode image myCode = QR(filename=filename) if myCode.decode(): text = myCode.data return text.lower() else: return False
def camera_decode(): camera = picamera.PiCamera() camera.resolution = (800, 600) try: count = 0 camera.start_preview() camera.brightness = 60 while True: camera.capture('pic.png') count += 1 print count myCode = QR(filename="pic.png") if myCode.decode(): print "Decoder working" user = str(myCode.data) camera.stop_preview() camera.close() return user break else: user = "" os.remove("pic.png") #camera = picamera.PiCamera() time.sleep(1) if count > 10: print "Could not detect QR code" user = "" camera.stop_preview() break except: user = "" print "error" camera.close() return user
def readqr(data): filename = "%s%s.bmp" %(imgpath,str(uuid.uuid4())) ##qr mappings cmap = {'0': (255,255,255), '1': (0,0,0)} ## clean up the data length = len(data.split("\n")) data = data.replace("\n","") ##build image rawdata = [cmap[letter] for letter in data] img = Image.new('RGB', (length, len(data)//length), "white") img.putdata(rawdata) img.save(filename, 'BMP') ##decode image myCode = QR(filename=filename) if myCode.decode(): text=myCode.data return text.lower() else: return False
def check_image_qr(self, path): myCode = QR(filename=path) if myCode.decode(): self.qr_link = myCode.data_to_string() self.copy_link.set_sensitive(True) alert = NotifyAlert(10) alert.props.title = _("Code found") alert.props.msg = _("Click on toolbar button for " "copy link to clipboard.") alert.connect("response", lambda x, y: self.activity.remove_alert(x)) self.activity.add_alert(alert) else: self.qr_link = None self.copy_link.set_sensitive(False) alert = NotifyAlert(10) alert.props.title = _("Code not found") alert.props.msg = _("Try again, please focus the Qr " "Code in the camera.") alert.connect("response", lambda x, y: self.activity.remove_alert(x)) self.activity.add_alert(alert) self.stop_play.set_sensitive(False)
def check_image_qr(self, path): myCode = QR(filename=path) if myCode.decode(): self.qr_link = myCode.data_to_string() self.copy_link.set_sensitive(True) alert = NotifyAlert(10) alert.props.title = _("Code found") alert.props.msg = _("Click on toolbar button for " "copy link to clipboard.") alert.connect("response", lambda x, y: self.activity.remove_alert(x)) self.activity.add_alert(alert) else: self.qr_link = None self.copy_link.set_sensitive(False) alert = NotifyAlert(10) alert.props.title = _("Code not found") alert.props.msg = _("Try again, please focus the Qr " "Code in the camera.") alert.connect("response", lambda x, y: self.activity.remove_alert(x)) self.activity.add_alert(alert) self.stop_play.set_sensitive(False)
#!/usr/bin/env python # encoding: utf-8 from qrtools import QR if __name__ == '__main__': qr = QR(filename='./qr-fix.png') if qr.decode(): print qr.data
for ss in mydivs: format_print(ss['value'], "ss") url = "https://ss.freess.org" r = requests.get(url, headers=headers) soup = BeautifulSoup(r.text, 'lxml') QR_imgs = soup.findAll("a", {"class": "image fit"}) for qrimg in QR_imgs: n, img = qrimg['href'].split(",") raw_img = base64.b64decode(img) tmp_f = random_string(5) fp = open(tmp_f, "wb") fp.write(raw_img) fp.close() myCode = QR(filename=tmp_f) if myCode.decode(): if (myCode.data_type == "text"): protocol, ss = myCode.data_to_string().split("://") format_print(base64.b64decode(ss), protocol) os.remove(tmp_f) url = "https://shadowsocksr.cat" r = requests.get(url, headers=headers) soup = BeautifulSoup(r.text, 'lxml') QR_img_urls = soup.findAll("a", {"class": "overlay lightbox"}) for qrimgurl in QR_img_urls: imgurl = url + "/" + qrimgurl['href'] r = requests.get(imgurl, headers=headers) tmp_f = random_string(5) imageFile = open(tmp_f, 'wb') for chunk in r.iter_content(100000):
from os import system from qrtools import QR from PIL import Image,ImageOps dir = "/home/l0l/CTF/Soal/Writeup/ctf-writeup/ASGamaCTF/Forensics/Behind The Scene" system("echo $(ls qr) > names") names = open("names","r").read()[:-1].split(' ') names.sort() chars = [] # invert color for i in names: im = Image.open("qr/{}".format(i)) im = ImageOps.invert(im) im.save("qr-inv/{}".format(i),"png") for i in names: myQR = QR(filename="qr-inv/{}".format(i)) myQR.decode() chars.append(myQR.data) print ''.join(chars)
from qrtools import QR import sys #import argparse arg = sys.argv code = QR(filename=arg[1]) if code.decode(): print "QR decoded data is : ", code.data print code.data_type print code.data_to_string()
def doQRDecoder(fileLocation): myCode = QR(filename = fileLocation) if myCode.decode(): print ("Data type: " + myCode.data_type + ": " + myCode.data)
# ls -tr ./qrcodemadness | xargs | python solve.py from qrtools import QR l = raw_input().split(' ') b = '' for i in l: myCode = QR(filename="./qrcodemadness/" + i) myCode.decode() b += myCode.data print b[58:].decode('base64').rstrip()
import pyqrcode from qrtools import QR # qr = pyqrcode.create("HORN O.K. PLEASE.") # qr.png("horn.png", scale=6) # for i in range (0,10): # qr = pyqrcode.create(str(i)+" s") # qr.png(str(i)+".png",scale=6) big_code = pyqrcode.create('0987654321', error='L', version=40, mode='binary') big_code.png('code.png', scale=6) big_code.show() my_QR = QR(filename="code.png") my_QR.decode() print my_QR.data
resolution_level = 9 num_cases = int(sys.stdin.readline()) for num_case in range(num_cases): text_squares = sys.stdin.readline().rstrip('\r\n').split() squares = [ parse_square(s) for s in text_squares ] s = squares[0] for i in range(1, len(squares)): s = add_squares(s, squares[i]) qrname = u'case%d_sum.png' % (num_case + 1) create_png(qrname, s, resolution_level) myCode = QR(filename=qrname) if myCode.decode(): #m = md5.new() #m.update(myCode.data_to_string()) #print m.hexdigest() secret = myCode.data_to_string() # Strip non iso-8859-1 characters secret = secret.decode('utf-8') secret = secret.encode('iso-8859-1', 'ignore') print secret
qrimg.paste(imgs[17], (220, 0)) # columns 2-3 could be swapped for a in [(6, 25), (25, 6)]: qrimg.paste(imgs[a[0]], (20, 0)) qrimg.paste(imgs[a[1]], (30, 0)) # columns 9-11 could be swapped for b in [(23, 21), (21, 23)]: qrimg.paste(imgs[b[0]], (90, 0)) qrimg.paste(imgs[b[1]], (110, 0)) # columns 10-12 could be swapped for c in [(19, 10), (10, 19)]: qrimg.paste(imgs[c[0]], (100, 0)) qrimg.paste(imgs[c[1]], (120, 0)) # columns 17-19 could be any permutation for d in itertools.permutations([24, 4, 22]): qrimg.paste(imgs[d[0]], (170, 0)) qrimg.paste(imgs[d[1]], (180, 0)) qrimg.paste(imgs[d[2]], (190, 0)) # try it qrimg.save("foo.png", "PNG") #qr = QR(qrimg) qr = QR(filename="foo.png") qr.decode() print qr.data
def decode(self, image): my_QR = QR() if my_QR.decode(image): # if the image is a recognizable QR Code return my_QR.data # return the value of that QR Code else: return None
def qrdecode(filename): qr = QR() qr.decode(filename) return qr.data