Hashing and encryption algorithms

I'm doing some work on the difference between Hash and encryption.

For me it is easier to talk about Hash and cite examples since I usually use SHA1 and MD5, but talking about encryption is difficult since I do not know any encryption algorithm.

I wanted examples closer to the everyday programmer, but I always end up finding only hashes and none of encryption in fact.

Can anyone cite examples of encryption?

Author: Mariana Bayonetta, 2018-06-20

1 answers

According to dictionary definitions, encryption is "a set of principles and techniques employed to encrypt writing, making it unintelligible to those who do not have access to the combined conventions".

That is, any algorithm that makes the content not readable 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: http://www.henryalgus.com

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);

Is a simple example that does a simple encryption, a practical example close to everyday programming as you mentioned.

Hash is already a mathematical calculation, which generate a numerical representation of a given. The main feature of hash is that it is not reversed, or" decrypted " so to speak, unlike the example above, or other commonly used algorithms, such as these:

  • Symmetric key encryption: the same key is used to encrypt encrypt and decrypt the data. Among the algorithms that use this technique are DES ( Data Encryption Standard ), and RC (Ron's Code or Rivest Cipher) (RC2, RC4, etc)

  • Asymmetric key encryption, or public key. It works with two keys: one private and one public. The public key is used to encrypt, and when sending data for someone (or somewhere), must send separately to a private key, so that the data can be decrypted. Some examples: RSA (Rivest, Shamir and Adleman ) and ElGamal

Other known algorithms, mainly in WiFi networks are WEB and WPA.

References: http://pcworld.com.br /

 4
Author: Ricardo Pontual, 2018-06-20 12:42:18