According to dictionary definitions, encryption is "a set of principles and techniques used to encrypt writing, make it unintelligible to those who do not have access to the combined conventions."
That is, any algorithm that renders the content unreadable or interpretable, we can think, in a simple way, as encryption, or even simpler, any algorithm that "shuffles" the data.
See the example below, which I took from this site: link
var jsEncode = {
encode: function (s, k) {
var enc = "";
var str = "";
// make sure that input is string
str = s.toString();
for (var i = 0; i < s.length; i++) {
// create block
var a = s.charCodeAt(i);
// bitwise XOR (operação lógica que "mexe" nos bits, gerando o efeito de "embaralhar" o caractere)
var b = a ^ k;
enc = enc + String.fromCharCode(b);
}
return enc;
}
};
var chave = "123";
var e = jsEncode.encode("Teste de criptografia",chave);
console.log("dados criptografados: " + e);
var d = jsEncode.encode(e,chave);
console.log("dados descriptografados: " + d);
It's a simple example that makes a simple encryption, a practical example close to everyday programming like you mentioned.
Hash is already a mathematical calculation, which generates a numeric representation of a given.
The main feature of the hash is that it is not reversed, or "decrypted" so to speak, unlike the above example, or other commonly used algorithms like these:
-
Encryption with symmetric key: The same key is used to encrypt encrypted and decrypted data.
Among the algorithms that use this technique are Data Encryption Standard (DES), and RC (RDS) or Rivest Cipher (RC2, RC4, etc.)
-
Encryption with asymmetric key, or public key.
It works with two keys: one private and one public. The public key is used to encrypt, and when sending the data to someone (or somewhere), you must send a private key separately so that the data can be decrypted.
Some examples:
RSA (Rivest, Shamir and Adleman) and ElGamal
Other known algorithms, especially in WiFi networks, are WEB and WPA.
References: link