1pass.lua
changeset 5 6f80cd157c13
parent 1 0919d17b13f9
child 6 b7f19e0599db
--- a/1pass.lua	Tue Dec 17 22:59:57 2013 -0500
+++ b/1pass.lua	Wed Dec 18 00:23:35 2013 -0500
@@ -57,7 +57,12 @@
 end
 
 
+local keys = {}
 function loadKey(basedir, level, password)
+    if keys[level] ~= nil then
+        return keys[level]
+    end
+
     local keysjson = load_json(basedir .. "/encryptionKeys.js");
     if (keysjson == nil) or (keysjson[level] == nil) then
         return nil
@@ -81,6 +86,7 @@
                 return nil
             end
 
+            keys[level] = decrypted
             return decrypted
         end
     end
@@ -109,8 +115,7 @@
 io.write("password: ")
 local password = io.read("*l")
 
-local sl5 = loadKey(basedir, "SL5", password)
-if sl5 == nil then
+if loadKey(basedir, "SL5", password) == nil then
     print("wrong password?\n")
     os.exit(1)
 end