Hashing and Regrex Flashcards
What is hashing
Hashing is a cryptographic process that can be used to validate the authenticity and integrity of various types of input.
Hashing is a way of transforming your a file into a unique identifier that are hard to invert and essentially reverse.
What is Hashing algroithm
A hashing algorithm is a cryptographic hash function. It is a mathematical algorithm that maps data of arbitrary size to a hash of a fixed size.
It is designed to be a one way function
Types of hashing algo
MD5, SHA, CRC
Describe MD
(MD stands for Message Digest): An MD5 hash function encodes a string of information and encodes it into a 128-bit fingerprint. It is one of the most commonly used yet amongst the most unsecure algorithms. Suffers extensive hash collision vunlerabilites
Describe SHA
Secure Hash Algorithm (SHA-0, SHA-1, SHA-2 family of algorithms) SHA-2 developed by the National Security Agency (NSA). The SHA-2 family consists of six hash functions with digests (hash values) that are 224, 256, 384 or 512 bits
Describe CRC
CRC (cyclic redundancy code):A cyclic redundancy check (CRC) is an error-detecting code often used for detection of accidental changes to data
Encoding the same data string using CRC32 will always result in the same hash output, thus CRC32 is sometimes used as a hash algorithm for file integrity checks.
Give an example of using the hash password techniques
MessageDigest msgDigest = MessageDigest.getInstance(“SHA-256”);
msgDigest.update((new String(msg)). getByte(“UT8”));
String hash = new String(msgDigest.digest());
Describe salt
Another best practice for secure password storage is to combine each password with a randomly generated string of characters called a “salt” and then to hash the result
Salting also prevents attackers from discovering duplicate passwords in a database. 16 characters long
Describe Pepper
To add another layer of security, in addition to salts, developers can also combine all passwords with a randomly generated string of at least 32 characters called a pepper.
Unlike a salt, which is unique for every password, the pepper is the same for all passwords but should not be stored inside the database.