What the name of the algorithm/encryption technique which outputs a set number of numerical digits e.g. 20 digits based on some input.

You can input some data e.g. text or numbers but the output is always 20 unique digits.

If you put the same input, it should give you the same output.

  • 3
    $\begingroup$ Do you mean a hash? $\endgroup$ – AleksanderRas Oct 4 '19 at 10:02
  • $\begingroup$ Thanks.. that's what I was looking for $\endgroup$ – spaghetti_code Oct 4 '19 at 11:39

Your question is not clear. Any deterministic compression functions an answer to your question.

$$C:\{0,1\}^* \to \{0,1\}^\ell$$ where $\ell$ is the output range, (20 numerical digits in your case and this may require some conversion from bits to digits).

A simple one is zipping with trimming. Zip the trim to 20 numerical digits.

However, in Cryptography we want the compression functions as one-way compression functions.

You may also be asking, the Cryptographic hash functions which are also one-way compression functions with pre-image resistance, secondary pre-image resistance, and collision resistance are required.

\begin{alignat*}{2} H:\{0,1\}^*&\longrightarrow& \{0,1\}^\ell \\ \mathbf{m}&\longmapsto& H(\mathbf{m}) \end{alignat*} where $\ell$ is the output range. The definitions of resistances are;

  • Pre-image resistant: given a hash value $h$ find a message $m$ such that $h=H(m)$. Consider storing the hashes of passwords on the server. Eg. an attacker will try to find a valid password to your account.

  • Second Pre-image resistant: given a message $m_1$ is should be computationally infeasible to find another message $m_2$ such that $m_1 \neq m_2$ and $H(m_1)=H(m_2)$. If possibe this can lead producing a forgery of a given message.

  • Collision resistance : if it is computationally infeasible to find two inputs $a$ and $b$ such that $H(a)= H(b)$ with $a \neq b.$

The generic attacks on hash functions have the following complexities:

$$ \begin{array} {r|r} & \text{Classical} \\ \hline \text{Preimage attack} & \Theta(2^{\ell})\\ \text{Second-preimage attack} & \Theta(2^{\ell}) \\ \text{Collision attack} & \Theta(2^{\ell/2}) \\ \end{array} $$

Your case, however, is a 20 numerical digits output, this is not secure since, 20 numerical digits has $\approx 67$ bits. In today standards, this is considered as trivially broken (computationally) since a collision attack with generic birthday attack on hash functions with $2^{67}$ output is $\sqrt{2^{67}} = 2^{33} \sqrt{2}$ with 50% probability. In, today's computing power, SHA-1 with 160-bit output is not considered secure for cryptography and removed from the standard.

You should use, at least, a secure hash function with around 256-bit output size like SHA-224, SHA-256, SHA-512 or SHA-3 series. You should not trim the output that falls into the computational feasibility of the attacks.

| improve this answer | |
  • 1
    $\begingroup$ Thanks for your comprehensive answer.. $\endgroup$ – spaghetti_code Oct 4 '19 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.