🔑 Encryption vs 🔒 Hashing
b6 last edited by b6
Encryption vs Hashing
Hashing. The two main terms in
cryptogrphy. We know both techniques are using to hide actual data in programming. But there are few major differences between.
Let's see the very basic concept & difference between Encryption and Hashing.
Encryption is the process of using an algorithm to transform information to make it unreadable for unauthorized users. - Techopedia
Encryptionis a kind of algorithm to transform the data to unreadable format or specific format that can't be read by anyone else.
It looks like,
Before Encrypt - Hi, How are you?
After Encrypt - dahj963hqd92h2hr2f hf9vb3y9863b52c3569
specific usercan decrypt the data.
The lenth of encrypted data depends on the actual data lenth. If you input small data, the encrypted data also will be smaller. If you input huge data, the encrypted data will be larger.
The encryption machanism has two type of keys.
1. Public Key - Open key that use to encrypt data.
2. Private Key - Secret key that use to decrypt the encrypted data.
Hashingis also working like
Hashdoesn't have keys like
Hashing's output doesn't depends on the input size. Its' output will be a fixed size of string.
It means, imagine the hashing function
hash()returns 32 characters output, The output will not be increased or decresed.
echo hash('a') 0cc175b9c0f1b6a831c399e269772661 //32 chars output echo hash('Data encryption translates data into another form, or code, so that only people with access to a secret key (formally called a decryption key) or password can read it. Encrypted data is commonly referred to as ciphertext, while unencrypted data is called plaintext. Currently, encryption is one of the most popular and effective data security methods used by organizations. Two main types of data encryption exist - asymmetric encryption, also known as public-key encryption, and symmetric encryption') fc2a2d702e1af572e4fe4dddb31ccc90 //32 chars output
The another thing is, We can't reverse the hash. It means we
canhash a data. But we
can'tget data again from hash.
Encryption Hashing Output length not Fixed Fixed Output length Can retrieve data again Can't retrieve data again Use as a trusted data Use as a trusted and unique identifier
When use Encryption and Hashing ?
Use cases of
- Store Passwords in Database.
- Compare file hashes for check damage (Check Sum).
- Compare data for difference or changes.
Use case of
- Store sensitive data.
- Transfer data over network / internet.
- Make dedicated file system / extensions.
lkdev last edited by
Good explanation, keep posting good luck
lahirunc last edited by
Nice Work! Keep up!
good work bro.. lankadevelopers are making a huge IT world in Sri Lanka
@lkdev Thank you for your support
@lahirunc Thanks bro
@root Yes. The srilanka's stack overflow
dev_lak last edited by dev_lak
nice explanation bro...
@dev_lak Thank you bro
MoRaL last edited by
cool explanation broh
@MoRaL Thank you bro
imadusanka last edited by
@isuru2014 Thx Bro