Re: Fun with keychain scripting....
Re: Fun with keychain scripting....
- Subject: Re: Fun with keychain scripting....
- From: Gnarlodious <email@hidden>
- Date: Thu, 22 Jan 2004 20:11:50 -0700
Not too sure what you're talking about, but here's how I do it:
tell application "Keychain Scripting"
set theUser to account of machineKey
set thePassword to the password of machineKey
set theServer to the server of machineKey
set theProtocol to the protocol of machineKey as string
end tell
set theURL to (text 1 thru ((offset of (ASCII character 32) in
theProtocol) - 1) of theProtocol) & "://" & theServer & "/" & theUser as
string
set thePassword to (text 1 thru ((offset of (ASCII character 0) in
thePassword) - 1) of thePassword)
I've discussed this with John Welch and he claims the password is a plain
text string, but it's not for me. It might depend on when your keychain was
invented.
I extract the password by taking the whole encryption string and truncating
the first ASCII nul character, which is invisible and undisplayable. That
might be what's tripping you up. If you get the length of it you'll see it's
some 32 bits long regardless of the actual length.
HTH
-- Gnarlie
Entity David Crowe spoke thus:
>
I'm trying to write a little utility that will obtain a password from
>
the keychain. So far I have:
>
>
display dialog "Enter name of key or password to view" default answer ""
>
set KeyName to text returned of the result
>
tell application "Keychain Scripting"
>
tell keychain "dad"
>
repeat with i from 1 to (count keys of it)
>
if (name of key i) begins with KeyName then
>
tell me to display dialog "Password="
>
& (password of key i)
>
return
>
end if
>
end repeat
>
>
end tell
>
end tell
>
tell me to display dialog "Did not find key <" & KeyName & ">"
>
>
>
Sometimes this work, but other times I get the error:
>
>
Can't make +class ppas; of +class ckey; 104 of +script; into a string
>
>
Since all the types of key inherit from the basic class "key", how
>
could there be a password that isn't a string (the dictionary defines
>
'password' as a string). Is it me? Or AppleScript?
>
>
>
Also, I'd like to eliminate the repeat loop (it's quite slow) but:
>
>
>
password of key whose name is "xyz"
>
>
doesn't work (error is "Can't get key whose name = "xyz".).
>
>
- David Crowe
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.