--- a/src/eric7/Utilities/crypto/__init__.py Thu Dec 21 15:46:22 2023 +0100 +++ b/src/eric7/Utilities/crypto/__init__.py Thu Dec 21 19:50:01 2023 +0100 @@ -33,8 +33,10 @@ """ Module function to encode a password. - @param pw password to encode (string) - @return encoded password (string) + @param pw password to encode + @type str + @return encoded password + @rtype str """ pop = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,;:-_!$?*+#" rpw = "".join(random.sample(pop, 32)) + pw + "".join(random.sample(pop, 32)) @@ -45,8 +47,10 @@ """ Module function to decode a password. - @param epw encoded password to decode (string) - @return decoded password (string) + @param epw encoded password to decode + @type str + @return decoded password + @rtype str """ if not epw.startswith(EncodeMarker): return epw # it was not encoded using pwEncode @@ -106,10 +110,12 @@ """ Module function to encrypt a password. - @param pw password to encrypt (string) - @param mainPW password to be used for encryption (string) - @return encrypted password (string) and flag indicating - success (boolean) + @param pw password to encrypt + @type str + @param mainPW password to be used for encryption + @type str + @return encrypted password (string) and flag indicating success + @rtype bool """ from .py3AES import encryptData from .py3PBKDF2 import hashPasswordTuple @@ -146,10 +152,12 @@ """ Module function to decrypt a password. - @param epw hashed password to decrypt (string) - @param mainPW password to be used for decryption (string) - @return decrypted password (string) and flag indicating - success (boolean) + @param epw hashed password to decrypt + @type str + @param mainPW password to be used for decryption + @type str + @return decrypted password (string) and flag indicating success + @rtype bool """ from .py3AES import decryptData from .py3PBKDF2 import rehashPassword @@ -179,11 +187,14 @@ """ Module function to re-encrypt a password. - @param epw hashed password to re-encrypt (string) - @param oldPassword password used to encrypt (string) - @param newPassword new password to be used (string) - @return encrypted password (string) and flag indicating - success (boolean) + @param epw hashed password to re-encrypt + @type str + @param oldPassword password used to encrypt + @type str + @param newPassword new password to be used + @type str + @return encrypted password (string) and flag indicating success + @rtype bool """ plaintext, ok = pwDecrypt(epw, oldPassword) if ok: @@ -198,10 +209,14 @@ In case of an error the encoded password is returned unchanged. - @param epw encoded password to re-encode (string) - @param oldPassword password used to encode (string) - @param newPassword new password to be used (string) - @return encoded password (string) + @param epw encoded password to re-encode + @type str + @param oldPassword password used to encode + @type str + @param newPassword new password to be used + @type str + @return encoded password + @rtype str """ if epw == "": return epw @@ -227,9 +242,12 @@ If there is an error, an empty code is returned for the encode function or the given encoded password for the decode function. - @param pw password to encode (string) - @param encode flag indicating an encode or decode function (boolean) - @return encoded or decoded password (string) + @param pw password to encode + @type str + @param encode flag indicating an encode or decode function + @type bool + @return encoded or decoded password + @rtype str """ if pw == "": return pw @@ -254,7 +272,8 @@ """ Module function to change the remembered main password. - @param newPassword new password to be used (string) + @param newPassword new password to be used + @type str """ global MainPassword MainPassword = pwEncode(newPassword) if newPassword else None @@ -264,14 +283,17 @@ """ Module function to encrypt a password. - @param data data to encrypt (bytes) - @param password password to be used for encryption (string) - @param keyLength length of the key to be generated for encryption - (16, 24 or 32) + @param data data to encrypt + @type bytes + @param password password to be used for encryption + @type str + @param keyLength length of the key to be generated for encryption (16, 24 or 32) + @type int @param hashIterations number of hashes to be applied to the password for - generating the encryption key (integer) - @return encrypted data (bytes) and flag indicating - success (boolean) + generating the encryption key + @type int + @return encrypted data (bytes) and flag indicating success + @rtype bool """ from .py3AES import encryptData from .py3PBKDF2 import hashPasswordTuple @@ -302,12 +324,14 @@ """ Module function to decrypt a password. - @param edata hashed data to decrypt (string) - @param password password to be used for decryption (string) - @param keyLength length of the key to be generated for decryption - (16, 24 or 32) - @return decrypted data (bytes) and flag indicating - success (boolean) + @param edata hashed data to decrypt + @type str + @param password password to be used for decryption + @type str + @param keyLength length of the key to be generated for decryption (16, 24 or 32) + @type int + @return decrypted data (bytes) and flag indicating success + @rtype bool """ from .py3AES import decryptData from .py3PBKDF2 import rehashPassword