Windows CMD treats the enclosing parameters as part of the parameter (part of the string).
If you want outer quotes to always be part of the string (even if they were not supplied on the command line), then you can do the following:
<nul set /p ^"="%~1"^" | openssl dgst -sha256 -binary 2>NUL | openssl base64 2>NUL
If you don't want the enclosing quotes to be included in the string, then you can generally do:
<nul set /p "=%~1" | openssl dgst -sha256 -binary 2>NUL | openssl base64 2>NUL
The above strategy generally works, but the SET /P hack for printing a string without \r\n at the end does not work if the string starts with space or =.
This is kind of a nasty problem. I imagine the best option is to switch to using powerShell. (I'm not very familiar with PowerShell, so I don't know the syntax).
If you really want to use batch, you can use a fairly complicated process to print any string without \r\n, described at https://stackoverflow.com/a/19468559/1012053