gKeyedStreamGenerator = do_CreateInstance("component:
nsCOMPtr<nsIKeyedStreamGenerator> keyGenerator = do_CreateInstance("component:
Wallet_GetKey(nsKeyType saveCount, nsKeyType writeCount) {  nsresult rv = NS_OK;  PRUint8 keyByte = 0;#ifndef DEBUG_dpgoto backup_noassert;#endif  if (!gKeyedStreamGenerator)  {    // Get a keyed stream generator    // XXX how do we get to the NS_BASIC_STREAM_GENERATOR progid/CID here    gKeyedStreamGenerator = do_CreateInstance("component://netscape/keyed-stream-generator/basic", &rv);    if (NS_FAILED(rv)) {      goto backup;    }    // XXX need to checkup signature  }  if (gNeedsSetup)  {    // Call setup on the keyed stream generator    nsCOMPtr<nsIWalletService> walletService = do_GetService(NS_WALLETSERVICE_PROGID, &rv);    if (NS_FAILED(rv)) {      goto backup;    }    nsCOMPtr<nsIPasswordSink> passwordSink = do_QueryInterface(walletService, &rv);    if (NS_FAILED(rv)) {      goto backup;    }    rv = gKeyedStreamGenerator->Setup(saveCount, passwordSink);    gNeedsSetup = PR_FALSE;  }  // Get the byte using the keyed stream generator  rv = gKeyedStreamGenerator->GetByte(writeCount, &keyByte);  if (NS_FAILED(rv)) {    goto backup;  }  return (PRUnichar)keyByte;backup:  // Fallback to doing old access  NS_ASSERTION(0, "Bad! Using backup stream generator. Email dp@netscape.com");backup_noassert:  NS_ASSERTION(key.Length()>0, "Master Password was never established");  if (key.Length() > 0 ) {    return key.CharAt((PRInt32)(writeCount % key.Length()));  } else {    return '~'; /* What else can we do?  We can't recover from this. */  }}