What is the best way to password protect folder/page using php without a db or username

Edit: SHA1 is no longer considered secure. Stored password hashes should also be salted. There are now much better solutions to this problem. You could use something like this: //access.php <?php //put sha1() encrypted password here – example is ‘hello’ $password = ‘aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d’; session_start(); if (!isset($_SESSION[‘loggedIn’])) { $_SESSION[‘loggedIn’] = false; } if (isset($_POST[‘password’])) { if … Read more

Password protecting a directory and all of it’s subfolders using .htaccess

It’s a simple two step process In your .htaccess put AuthType Basic AuthName “restricted area” AuthUserFile /path/to/the/directory/you/are/protecting/.htpasswd require valid-user use http://www.htaccesstools.com/htpasswd-generator/ or command line to generate password and put it in the .htpasswd Note 1: If you are using cPanel you should configure in the security section “Password Protect Directories” EDIT: If this didn’t work … Read more

HTTP authentication logout via PHP

Mu. No correct way exists, not even one that’s consistent across browsers. This is a problem that comes from the HTTP specification (section 15.6): Existing HTTP clients and user agents typically retain authentication information indefinitely. HTTP/1.1. does not provide a method for a server to direct clients to discard these cached credentials. On the other … Read more

SQLite with encryption/password protection

SQLite has hooks built-in for encryption which are not used in the normal distribution, but here are a few implementations I know of: SEE – The official implementation. wxSQLite – A wxWidgets style C++ wrapper that also implements SQLite’s encryption. SQLCipher – Uses openSSL’s libcrypto to implement. SQLiteCrypt – Custom implementation, modified API. botansqlite3 – … Read more

Reading a password from std::cin

@wrang-wrang answer was really good, but did not fulfill my needs, this is what my final code (which was based on this) look like: #ifdef WIN32 #include <windows.h> #else #include <termios.h> #include <unistd.h> #endif void SetStdinEcho(bool enable = true) { #ifdef WIN32 HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); DWORD mode; GetConsoleMode(hStdin, &mode); if( !enable ) mode &= … Read more