Hash and Cryptography Algorithms

2

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

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

I wanted examples that were closer to the programmer's everyday life, but I always find only hashs and none of the actual encryption.

Can anyone cite examples of cryptographic algorithms?

    
asked by anonymous 20.06.2018 / 14:08

1 answer

4

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

    
20.06.2018 / 14:42