Porównaj commity

...

4 Commity

Autor SHA1 Wiadomość Data
robinmoisson 656a29c0b0
formating 2023-06-13 11:08:32 +02:00
robinmoisson 96dcee940b
update readme with community project 2023-06-13 11:07:55 +02:00
robinmoisson b76fdff928
update readme with overwriting file trick 2023-06-13 10:58:18 +02:00
robinmoisson 9cf3f5d212
fix remember=false (closes #178) 2023-06-13 10:29:31 +02:00
6 zmienionych plików z 34 dodań i 24 usunięć

Wyświetl plik

@ -64,6 +64,14 @@ staticrypt dir_to_encrypt/* -r
# => encrypted files are in encrypted/...
```
**Replace all the files in a folder with encrypted ones**:
```bash
# 'dir_to_encrypt/*' as argument will select all the files in the directory ('-r' recursively), and the
# '-d dir_to_encrypt' will put them in the same directory, overwriting the files
staticrypt dir_to_encrypt/* -r -d dir_to_encrypt
```
**Encrypt a file and get a shareable link containing the hashed password** - you can include your file URL or leave blank. (⚠️ you should keep your `.staticrypt.json` so the salt is the same each time you encrypt, or re-encrypting will [invalidate the link](#why-does-staticrypt-create-a-config-file)):
```bash
@ -74,14 +82,14 @@ staticrypt test.html --share https://example.com/encrypted.html
**Pin the salt to use staticrypt in your CI in a build step** - if you want want the "Remember-me" or share features to work accross multiple pages or multiple successive deployment, the salt needs to stay the same ([see why](https://github.com/robinmoisson/staticrypt#why-does-staticrypt-create-a-config-file)). If you run StatiCrypt in a CI step, you can pin the salt in two ways:
```bash
# either commit the .staticrypt.json config file - you can generate a random salt and
# config file on your local machine with:
staticrypt --salt
- either commit the `.staticrypt.json` config file - you can generate a random salt and config file on your local machine with `staticrypt --salt`
- or hardcode the salt in the encryption command in the CI script:
# or hardcode the salt in the encryption command in the CI script:
staticrypt test.html --salt 12345678901234567890123456789012
```
```bash
staticrypt test.html --salt 12345678901234567890123456789012
```
See an exemple of how to use StatiCrypt in a CI build step in this community project: [a-nau/password-protected-website-template](https://github.com/a-nau/password-protected-website-template)
**Customize the password prompt** to have the encrypted page match your style (see [the FAQ](#can-i-customize-the-password-prompt) for a full custom template):
@ -123,11 +131,11 @@ The password argument is optional if `STATICRYPT_PASSWORD` is set in the environ
use that instead. [string] [default: null]
-r, --recursive Whether to recursively encrypt the input
directory. [boolean] [default: false]
--remember Expiration in days of the "Remember me"
checkbox that will save the (salted + hashed)
password in localStorage when entered by the
user. Set to "false" to hide the box. Default:
"0", no expiration. [number] [default: 0]
--remember Integer: expiration in days of the "Remember
me" checkbox that will save the (salted +
hashed) password in localStorage when entered
by the user. Set to "false" to hide the box.
Default: "0", no expiration. [default: 0]
-s, --salt Generate a config file or set the salt
manually. Pass a 32-character-long hexadecimal
string to use as salt, or leave empty to
@ -289,10 +297,10 @@ Here are some other projects and community resources you might find interesting
If you have a StatiCrypt project you'd like to share, feel free to open an issue describing it.
### Based on StatiCrypt, tutorials and projects
**Template to host an encrypted single page website with Github Pages:** [a-nau/password-protected-website-template](https://github.com/a-nau/password-protected-website-template) is a demonstration of how to build a protected page on Github Pages, integrating with Github Actions.
### Alternatives to StatiCrypt
[MaxLaumeister/PageCrypt](https://github.com/MaxLaumeister/PageCrypt) is a project with similar features in a different style (I think it was created before StatiCrypt).
### Based on StatiCrypt
**Template to host an encrypted single page website with Github Pages:** [a-nau/password-protected-website-template](https://github.com/a-nau/password-protected-website-template) is a demonstration of how to build a protected page on Github Pages, integrating with Github Actions. (**Warning:** this is compatible with 2.x only, left it here for inspiration purpose. You can follow the [issue on upgrading to 3.x](https://github.com/a-nau/password-protected-website-template/issues/2).)
[MaxLaumeister/PageCrypt](https://github.com/MaxLaumeister/PageCrypt) is a project with similar features in a different style (I think it was created before StatiCrypt).

Wyświetl plik

@ -359,9 +359,8 @@ function parseCommandLineArguments() {
default: false,
})
.option("remember", {
type: "number",
describe:
'Expiration in days of the "Remember me" checkbox that will save the (salted + hashed) password ' +
'Integer: expiration in days of the "Remember me" checkbox that will save the (salted + hashed) password ' +
'in localStorage when entered by the user. Set to "false" to hide the box. Default: "0", no expiration.',
default: 0,
})

Wyświetl plik

@ -193,10 +193,13 @@ async function encodeAndGenerateFile(
// encrypt input
const encryptedMsg = await encodeWithHashedPassword(contents, hashedPassword);
let rememberDurationInDays = parseInt(namedArgs.remember);
rememberDurationInDays = isNaN(rememberDurationInDays) ? 0 : rememberDurationInDays;
const staticryptConfig = {
staticryptEncryptedMsgUniqueVariableName: encryptedMsg,
isRememberEnabled,
rememberDurationInDays: namedArgs.remember,
rememberDurationInDays,
staticryptSaltUniqueVariableName: salt,
};
const templateData = {

Wyświetl plik

@ -768,7 +768,7 @@ exports.init = init;
})());
const templateError = "Bad password!",
isRememberEnabled = true,
staticryptConfig = {"staticryptEncryptedMsgUniqueVariableName":"85cf880a1573985224adbac66ceeba6c026484ad101ffabc6bc0d874a1e4eb75ddee7d265055e80d8e87369a694f873ff044933e1b5d33c46a636e2fdc4f2d108f0dd36252aba4c2e0f71a8e9ed2027839a6ea46a3e3a5f8e0d205046966c3bd1eac8b78e5ba3a5d9015eea2e0d83629d19c47e0b2311966aa7d3ac2fb8b592276484fea27cd90e5e85e65c11abd483a3d938b738efb02d290e94c9d249844f157667be667ed018f0d0e7702f141ef713c8cc2b472e25922d70cb75955a4182b","isRememberEnabled":true,"rememberDurationInDays":0,"staticryptSaltUniqueVariableName":"b93bbaf35459951c47721d1f3eaeb5b9"};
staticryptConfig = {"staticryptEncryptedMsgUniqueVariableName":"2271533ff6ba1c6223131c45fe772d77252bb175b03931aaabb9a4be7450f21edd6e55ab868304a493ffb7b5cb4d42ea21c0572063343d472699afd770cb115b6934a767bb7167c6c2737ca06671349e8ebf30bdd24f21f864c522197de1f223399a46c83694428ec32733f9c908697f240c597bea92679e607fe7c1021b2b5795eaf87dc65d981585d6b280ed953a3d744614230c709e09be866f6dfbecc169a31425efed49fc9dd6372b6a3148d9a9612dd3e9a44be08199c89a948a8609b7","isRememberEnabled":true,"rememberDurationInDays":0,"staticryptSaltUniqueVariableName":"b93bbaf35459951c47721d1f3eaeb5b9"};
// you can edit these values to customize some of the behavior of StatiCrypt
const templateConfig = {

4
package-lock.json wygenerowano
Wyświetl plik

@ -1,12 +1,12 @@
{
"name": "staticrypt",
"version": "3.3.0",
"version": "3.3.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "staticrypt",
"version": "3.3.0",
"version": "3.3.1",
"license": "MIT",
"dependencies": {
"dotenv": "^16.0.3",

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "staticrypt",
"version": "3.3.0",
"version": "3.3.1",
"description": "Based on the [crypto-js](https://github.com/brix/crypto-js) library, StatiCrypt uses AES-256 to encrypt your input with your long password and put it in a HTML file with a password prompt that can decrypted in-browser (client side).",
"main": "index.js",
"files": [