Can you make a number smaller without losing data? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you make a number smaller without losing data?

if we have a number of about 100 digits can we make it anumber of about 10 or 20 digits or something smaller by using some algorithm with a condition that we can get back the long number from the small number without losing data. i think it us something like hashing but the difference is that we can get the firist number again. sorry for my English :-/

10th Mar 2018, 8:52 AM
‎Mahmoud Abas
‎Mahmoud Abas - avatar
5 Answers
+ 4
@Meru Mario Egie, Thanks for sharing : )
10th Mar 2018, 11:13 AM
Ipang
+ 3
Excuse me, but which type of numeric data can support 100 digits? @Meru Mario Egie, how do we get original value after it is hashed by MD5? also how hex2bin can reduce a number's digit count? I would like to know, please tell me...
10th Mar 2018, 10:44 AM
Ipang
+ 1
in PHP Md5($variable) hashes $variable, and we can use md5 on the hashed variable to get the original value! Also see hex2bin() php
10th Mar 2018, 10:13 AM
Strange
Strange - avatar
+ 1
hex2bin — Decodes a hexadecimally encoded binary string the binary string can be very long but will be decided to an hexadecimal string. And if it's useful here I don't really know because the question isn't clear but I thought it was worth looking up. Md5() is used in password hashing mostly. practical example: $pass = Solo1earn ;//user input $pass = md5($pass); //this gives a large binary data and is what u store in the database but the user doesn't know this! he logs in with same Solo1earn, and though we can't directly unhash the saved password we can hash the user input and compare if they are equivalent. and if we prove that A=C and B=A then B=C is true.
10th Mar 2018, 11:07 AM
Strange
Strange - avatar
+ 1
sure Ipang
10th Mar 2018, 11:20 AM
Strange
Strange - avatar