Browse Source

fix(hugo-encryptor.py): fix password error when encrypt more than one post

Li4n0 6 years ago
parent
commit
706f7ea6de
2 changed files with 2 additions and 2 deletions
  1. 1 1
      hugo-encryptor.py
  2. 1 1
      shortcodes/hugo-encryptor.html

+ 1 - 1
hugo-encryptor.py

@@ -23,7 +23,6 @@ class AESCrypt(object):
 
 
 if __name__ == '__main__':
-    md5 = hashlib.md5()
     for dirpath, dirnames, filenames in os.walk('./public'):
         for filename in filenames:
             if not filename.lower().endswith('.html'):
@@ -39,6 +38,7 @@ if __name__ == '__main__':
 
             else:
                 print(fullpath)
+                md5 = hashlib.md5()
                 md5.update(block['data-password'].encode('utf-8'))
                 key = md5.hexdigest()
                 cryptor = AESCrypt(key)

+ 1 - 1
shortcodes/hugo-encryptor.html

@@ -76,6 +76,7 @@ your content
           ) {
             cipher.parentElement.outerHTML = decrypted_text;
             userStorage.setItem(storageKey, password);
+            document.getElementById("verifyText").outerHTML = "";
           } else {
             if (type === "input") {
               alert('{{ if eq .Site.Params.hugoEncryptorLanguage "en-us" }}wrong password{{ else }}密码错误{{ end }}');
@@ -83,7 +84,6 @@ your content
               userStorage.removeItem(storageKey);
             }
           }
-          document.getElementById("verifyText").outerHTML = "";
         } catch (error) {
           // console.log(error);
           if (type === "input") {