property pass : {{1, 0, 1, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 0, 1, 1, 1}, {1, 1, 0, 1, 1, 1, 1}, {1, 1, 1, 0, 0, 1, 0}, {1, 1, 1, 0, 1, 0, 0}, {1, 1, 0, 0, 0, 1}} -- Passwort als binäre Liste, pro Buchstabe eine Liste
-- Passwortabfrage:
repeat
set theAnswer to text returned of (display dialog "Passwort:" default answer "")
if isValid(theAnswer) then
display dialog "richtig"
exit repeat
end if
end repeat
-- restlicher Programmcode:
-------------------------------
-- Subroutine zum Prüfen des Passworts
-- Eingabe: text
-- Rückgabe: true oder false
on isValid(theKey)
textToBin(theKey) is pass
end isValid
-- Subroutine zum Umwandeln von Text in binäre Listen
-- Eingabe: Text
-- Ausgabe: Liste mit Binären Listen
on textToBin(theText)
set theBins to {} -- Liste erstellen
repeat with anId in id of theText-- id ist der ASCII-Wert des Buchstabens
set end of theBins to decToBin(anId) -- Binäre Liste für den ASCII-Wert an die Liste anhängen
end repeat
return theBins
end textToBin
-- Subroutine zum Umwandeln vom Dezimal- ins Binärsystem nach dem Horner Schema
-- Eingabe: Zahl
-- Ausgabe: Binäre Liste
on decToBin2(num)
set binary to {}
repeat
set beginning of binary to num mod 2
set n to n div 2
if n < 1 then
exit repeat
end if
end repeat
return binary
end decToBin2