If an attacker has a chosen-plaintext and encrypted data, can they determine the encryption type? This question differs from How to determine what type of encoding/encryption has been used?, which asked about a ciphertext-only attack. This question is asking about a chosen-plaintext attack.



Let's say an attacker was trying to perform a chosen-plaintext attack on an encrypted password server. This attacker is an internal employee with their own registered account. They can:


Specify an arbitrary plaintext password for their account.
View encrypted ciphertext passwords saved to the server.


This attacker doesn't know what encryption method is being used, whether passwords are salted, or what key is being used. However, they notice that the encrypted passwords are always the same number of characters (64).

Using their chosen plaintext and encrypted passwords, could an attacker determine what type of encryption was used?
In fact, good password hashing libraries do not try to hide the used algorithm but document it instead, because it allows to transparently change to a better algorithm without knowing the user passwords: when a user tries to login, the library looks at the registered hash and uses the documented algorithm to compute the hash from the clear text password. If then do not match, login is rejected. If they match and the algorithm is the current one, access is granted and nothing more happens, but if they match and the algo is not the current one, a new hash with the current algo is registered. For example, Modular Crypt Format prepends the hash with $digit$ where digit is (from man crypt):


       1.   MD5
       2.   Blowfish
       3.   NT-Hash
       4.   (unused)
       5.   SHA-256
       6.   SHA-512

Other crypt formats may be easily added.  An example salt would be:

      $4$thesalt$rest



If you are in that case, only one single hashed password is enough to know the used algorithm, and it is not a security problem, provided the algorithm is non invertible.