def print_wifi_token(message): try: data = WiFiPasswordData.fromstring(message[0].data) print " Wi-Fi Password Token" print " version = %d.%d" % data.version print " PK Hash = %s" % data.public_key_hash.encode("hex") print " DevPwdID = %s" % data.device_password_id print " Password = %s" % data.device_password.encode("hex") for key, val in data.other_attributes: print " 0x%04x = %s" % (key, val.encode("hex")) return except ValueError: pass try: data = WiFiConfigData.fromstring(message[0].data) print " Wi-Fi Configuration Token" print " version = %d.%d" % data.version print " network = %s" % data.ssid print " password = %s" % data.network_key print " macaddr = %s" % data.mac_address print " security = %s / %s" % \ (data.authentication, data.encryption) return except ValueError: pass
def write_password_token(tag): print print "Writing Wi-Fi Password Token" pwd = WiFiPasswordData() pwd.public_key_hash = 20 * "\x01" pwd.device_password_id = 100 pwd.device_password = "******" pwd.other_attributes.append((0x1023, "VAIO X11")) # model name message = Message(Record(("application/vnd.wfa.wsc", "", pwd.tostring()))) print format_data(message.tostring()) if tag: tag.ndef.message = message.tostring() return
def write_password_token(tag): print print "Writing Wi-Fi Password Token" pwd = WiFiPasswordData() pwd.public_key_hash = 20 * '\x01' pwd.device_password_id = 100 pwd.device_password = "******" pwd.other_attributes.append((0x1023, "VAIO X11")) # model name message = Message(Record(("application/vnd.wfa.wsc", "", pwd.tostring()))) print format_data(message.tostring()) if tag: tag.ndef.message = message.tostring() return