Re: Fast KeyChain Functions...
Re: Fast KeyChain Functions...
- Subject: Re: Fast KeyChain Functions...
- From: kai <email@hidden>
- Date: Wed, 25 May 2005 22:33:17 +0100
On Wednesday, May 25, 2005, at 03:45 pm, David Crowe wrote:
Let's say that I want to get the password for a key with the name
"PayPal Account". Since I can't use AppleScript to directly ask
KeyChain Scripting for the key by name, I have to do a scan through
the list by key number. Since the list is not ordered in any obvious
fashion, no optimizations such as a binary search are possible.
Consequently, a linear scan is necessary, and that takes many seconds
just to find one key. So, although the scripting is very simple, it's
also unacceptably slow.
By building an index on disk it's possible to identify the key number
quite quickly, and then access the key by number.
The complexity comes because when a key is added to or removed from
the keychain, the index is out of synch, and then a limited amount of
scanning is required to repair the index. Scanning can be limited in
this case because key indexes don't move increase or decrease than the
number of keys that have been added or removed
Thanks for the explanation, David.
Just so that I'm absolutely clear on this, would you say that a simple
script like the one below doesn't achieve the above aim - or just
doesn't do it fast enough? I ask because I haven't found a particular
problem so far - either with functionality or performance, but your
experience may vary.
--------
property k : ""
set m to "Please enter a key to find its password:"
repeat
set k to (display dialog m default answer k buttons ¬
{"Cancel", "Find…"} default button 2)'s text returned
try
tell application "Keychain Scripting" to tell current keychain ¬
to set pwd to password of first key whose name is k
set m to "The password for \"" & k & "\" is: \"" & pwd & "\"."
on error number n
if n is -128 then error number n
set m to "Could not get password for \"" & ¬
k & "\". Please try again:"
end try
end repeat
--------
At 8:11 AM +0100 5/25/05, kai wrote:
On Wednesday, May 25, 2005, at 03:46 am, David Crowe wrote:
Yes, this works, now try using it to figure out which of several
hundred keys you want ... you'll be waiting quite a long time.
- David
At 11:40 PM +0100 5/24/05, kai wrote:
On Tuesday, May 24, 2005, at 09:47 pm, David Crowe wrote:
The inability of the KeyChain to process commands like "key whose
name is..." makes access unbearably slow.
Doesn't something like this work for you, David?
----------------
tell application "Keychain Scripting" to first key of ¬
keychain "keychainName" whose name is "keyName"
----------------
Sorry David, clearly I misunderstood your opening sentence - and
can't quite grasp the nature of the problem. :-)
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden