from microbit import *
from mb_radio import *
from mb_file import *
from mb_disp import *
from mb_music import *

radio.on()
radio.config(length=250, channel=12,power=6,group=1)
disp_clr()
print("Waiting for message...")

while not escape():
  hash = radio.receive()
  if hash != None:
    break
print("Hash:", hash, "\nreceived")
print("Authenticating...")
authentic_hash = read_file("password.txt")
if hash == authentic_hash:
  print("Passed!")
  display.show("Image.YES")
  music.play('music.POWER_UP')
else:
  print("Denied access")
  display.show("Image.NO")
  music.play('music.POWER_UP')
