Live data from Hacker News

Password protect a static HTML page

github.com

181–190 of 294 posts

Re: Password protect a static HTML page

#181
post #170
post #163

Earlier quoted context omitted.

Why not use a password protected word document if those are your use-cases?

You definitely could. But I think there are more computers with web browsers than there are computers that can read encrypted Microsoft Word documents.

On client systems, PDF readers are as ubiquitous as browsers. An encrypted PDF should do the job better than Word.

Re: Password protect a static HTML page

#183

Gad! I have spent all morning trying to --- password protect a static html page. How in the hell does HN have a story about the exact topic I've been struggling with appear just a dozen or so hours after I started working on it. Wow. I was _extremely_ happy to see this posted. However when I click the link I am taken to the library I had initially tried and had to reject. Without getting into the crypto side of thing…

If your server supports it, a fast and easy way to password protect a page is to put it in a folder and password protect that folder with htaccess:

https://ithemes.com/blog/what-is-the-htaccess-file/#password...

Re: Password protect a static HTML page

#184

Gad! I have spent all morning trying to --- password protect a static html page. How in the hell does HN have a story about the exact topic I've been struggling with appear just a dozen or so hours after I started working on it. Wow. I was _extremely_ happy to see this posted. However when I click the link I am taken to the library I had initially tried and had to reject. Without getting into the crypto side of thing…

https://github.com/robinmoisson/staticrypt#encrypting-multip...

> This allows encrypting multiple page on a single domain with the same password

This might still work for you if putting everything on one page isn't a requirement. Using the "remember me" checkbox means the user only has to input this password once.

Re: Password protect a static HTML page

#185
post #138

The downside to this method is that since the resulting cryptographic hash and salt have to be in the resulting file, so there is nothing stopping someone from pulling the hash/salt out and bruteforcing it locally (as opposed to being able to ratelimit login attempts on a server) if they are so inclined and have the required resources.. which may not be that much in the way of resources as the tool uses 1000 iteratio…

Is it a downside if the password is a 100 characters-long string?

A fellow cryptographer in the security board on stack exchange has shared their opinion on this: https://security.stackexchange.com/questions/3959/recommende...

TLDR: No. In fact, theoretically stretching the password is more effective than increasing iterations. However, I don't see him citing the fact some password hashing functions have limited input size, which means at some point having a larger password doesn't really change anything.

Re: Password protect a static HTML page

#186

Earlier quoted context omitted.

I thought that too, but this appears like it works to password protect an html file that's *not* being served off a server. This ought to work with a file on disk too.

The more general solution is to use a password-protected archive.

But then it's not self contained and every time you want to access the archive you also need a program that can decrypt/encrypt that format. Using a self-contained HTML file means it's currently the most portable way to encrypt something and have it available anywhere you can get the file on.

By the way, I don't advocate for this idea. But still, I find it a pretty ingenious way to store encrypted data portably. Essentially what is happening is the file contains the encrypted data and the algorithm to decrypt it with the correct passphrase/key.

Re: Password protect a static HTML page

#187
post #159

Use apache to serve your page and htpasswd to provide basic authentication. Easy 1994 answer

Also NGINX auth basic option. I use it on my personal website. https://docs.nginx.com/nginx/admin-guide/security-controls/c...

Don't they all do? Lighttpd does: https://www.cyberciti.biz/tips/lighttpd-setup-a-password-pro...

Re: Password protect a static HTML page

#189
post #76

Earlier quoted context omitted.

Nobody implements GCM themselves; they get it from a library. CBC, implemented the way you're describing, is almost always insecure.

And the library they use doesn't have GCM mode. So now what? https://cryptojs.gitbook.io/docs/ Because CBC mode is easier to implement, you'll find it in far more libraries. And honestly, if your underlying block-cipher is secure (that's the hard part: where your side-channels all exist), then CBC mode is really the easy part and can be safely implemented yourself. It really is that simple. ----------------- CBC does…

> CBC doesn't have authentication. So add on an HMAC. Done

Literally one of the most common things to fuck up when doing crypto yourself.

Post reply on HN