tell application "Keychain Scripting"
set myTestPassword to the name of every key of keychain 1 whose name is "myTestPassword"
end tell
tell application "Keychain Scripting"
tell keychain 1
set chosenKey to the first generic key whose name is (myTestPassword as string)
set chosenPassword to the password of chosenKey
end tell
end tell
-- do something with your password
set the sourceString to the text returned of (display dialog " Enter your password" default answer "" with hidden answer)
if sourceString is in chosenPassword then
tell application "SystemUIServer" to display dialog "You have the correct password"
else
tell application "SystemUIServer" to display dialog "You have the wrong password"
end if