Linux has plenty of powerful encryption software, but what can you use if you just want to secure a couple files quickly? The OpenSSL toolkit works well for this. It comes installed with Ubuntu and can provide stronger encryption than you would ever need.
This is the basic command to encrypt a file:
openssl aes-256-cbc -a -salt -in secrets.txt -out secrets.txt.enc
How does this work?
It’s not much use unless you can decrypted it:
openssl aes-256-cbc -d -a -in secrets.txt.enc -out secrets.txt.new
But this does not make use of the public key infrastructure at all, so a bit like hammering in a nail with a screwdriver :-)
I recently decided that I wanted to lengthen the session lifetime on one of my web applications so that my users wouldn’t need to log in as frequently. However, I wanted to keep a shorter session time for the administration part of my site to keep it more secure.
Setting custom cookie lifetime:
ini_set('session.cookie_lifetime', 86400);
ini_set('session.gc_maxlifetime', 86400);
session_start();
Defining the duration of your user’s session is something that you definitely want to consider from the outset of your development. It can affect key aspects of your application’s success, like usability and security. For example, a long browser session may increase usability, but it also means that if your user does not explicitly log out to clear the cookie for your site, then another user could come along and access the first user’s data. One way to avoid this would be to design your application so that users may access some basic features for a long time, but must re-authenticate to access more secure features like account settings. Another strategy could be to set individual session lifetimes for different areas on your site.
Setting custom cookie directory:
ini_set('session.save_path', '/admin/data/tmp/session');
ini_set('session.cookie_lifetime', 1200);
ini_set('session.gc_maxlifetime', 1200);
session_start();
Using OpenSSH on a Linux/Unix system you can tunnel all of the traffic from your local box to a remote box that you have an account on.
ssh user@personal-server.com -L 2000:personal-server.com:25
Wrong way:
function myFunc(requiredArg, optionalArg){
optionalArg = optionalArg || 'defaultValue';
//do stuff
}
the logic fails if optionalArg is passed, but evaluates as false - use this as an alternative:
optionalArg = (typeof optionalArg === "undefined") ? "defaultValue" : optionalArg;
Works on almost all browsers. Implemented getJSON and postJSON methods. For everything else use make();
Example:
var ajax = new MY.VanillaAjax();
ajax.getJSON("http://httpbin.org/get?hello=world", function(data) {
console.log(data);
});
var data = JSON.stringify({
name: "tommy",
pass: "qwerty"
});
ajax.postJSON("http://httpbin.org/post", data, function(data) {
console.log(data);
});
Issues: