Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update usage for generatePassword() in README #43

Closed
Greenheart opened this issue Mar 21, 2023 · 1 comment
Closed

Docs: Update usage for generatePassword() in README #43

Greenheart opened this issue Mar 21, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Greenheart
Copy link
Owner

See updated docstring here:

pagecrypt/src/core.ts

Lines 60 to 82 in c850468

/**
* Encrypt an HTML string with a given password.
* The resulting page can be viewed and decrypted by opening the output HTML file in a browser, and entering the correct password.
*
* @param {string} inputHTML The HTML string to encrypt.
* @param {string} password The password used to encrypt + decrypt the content.
* @param {number} iterations The number of iterations to derive the key from the password.
* @returns A promise that will resolve with the encrypted HTML content
*/
export async function encryptHTML(
inputHTML: string,
password: string,
iterations: number = 2e6,
) {
return (decryptTemplate as string).replace(
/<!--ENCRYPTED PAYLOAD-->/,
`<pre class="hidden" data-i="${iterations.toExponential()}">${await getEncryptedPayload(
inputHTML,
password,
iterations,
)}</pre>`,
)
}

It's also important to enforce the max length of the character set = 256 characters. This should likely be in the docstring too, so we could update generatePassword() too to reflect that.

@Greenheart Greenheart added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 21, 2023
@Greenheart
Copy link
Owner Author

Will be resolved in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant