I don't know what application you are communicating with, but this makes sense.
The OpenSSL passwd
command hashes the input, it does not encrypt it. This may seem like a pedantic difference, but it is quite important in understanding what is actually happening here and why. Encryption is a reversible protection operation requiring special knowledge of secret material (i.e. the key) (reversibly protecting data without requiring a key is called encoding, and includes Base64, hexadecimal, etc.). Finally, hashing is a non-reversible protection operation requiring no secret data. The point of hashing is to use a deterministic algorithm to take some input data and transform it to output data from which it is extremely difficult (read: mathematically unlikely) to be able to determine the original input.
Why is this used for password storage instead of encryption? Because in order to encrypt and decrypt the raw passwords, you need an encryption key. If a malicious entity gains access to this encryption key, they have access to all of the raw passwords. Similarly, if they can brute force one of the passwords and recover that key, they get all of the passwords. By hashing the raw passwords instead, leaked/stolen "hashes" do not expose the original raw passwords, and the application can evaluate the raw password when provided for login without ever storing the raw password (because the hash function is deterministic and will always return the same output for the same input).
Specifically, passwd -1
tells OpenSSL to use "MD5-based BSD password algorithm 1". While this is not a very strong hashing algorithm, it is common because of its early usage. Your second attempt is simply Base64-encoding the raw password.
Now, the reason it works when you send the original password but neither of the two transformations is as follows -- the application will perform whatever hashing operation it needs to to translate your raw (original) password to the hashed form. If you try to already provide the password in this hashed form, it will fail to validate, because H(x) != H(H(x))
-- the hash of a hash is not equal to the original hash (for any non-trivial and well-designed hash function). You need to send the original password to the application in order to successfully authenticate (you can also research "client-side hashing" but it is almost always used in conjunction with server-side hashing for resource balancing, not as a replacement).
My takeaway here is that you are trying to "protect" your password when you send it over the network connection to your application to prevent eavesdropping. The way to do this is to enable HTTPS (preferably using TLSv1.1+) for the application so that all communications between the client and server are encrypted using an ephemeral session key (negotiated between the client and server in a protected handshake process encrypted via the public key contained in the server certificate). Then, when you send the credentials, they will only be recoverable by the server which holds the corresponding private key.
TL;DR Don't manipulate your password prior to sending via cURL; use TLS instead.