Command:
openssl> dgst-dss1-sign c.pri-out Signature.bin s.txt
Explain
C.pri is the private key file generated by the DSA algorithm
S.txt is the original of the signature.
Signature.bin is the generated signature file
PHP can use the following methods to view the content of the signature
The code is as follows |
Copy Code |
<?php Echo Bin2Hex (file_get_contents (' Signature.bin ')); ?> |
The
Reference
Message digest algorithm
supported algorithms include: MD2, MD4, MD5, MDC2, SHA1 (sometimes called DSS1), RIPEMD-160. SHA1 and RIPEMD-160 produce 160-bit Harlem values, while others produce 128-bit. It is recommended that you use SHA1 or RIPEMD-160 unless you are considering compatibility.
All other algorithms can be executed using the DGST command, except for the RIPEMD-160 need to use the rmd160 command.
OpenSSL is a bit strange for SHA1 to handle, and sometimes it has to be referred to as DSS1. The
Message digest algorithm can also be used for signing and verifying signatures, in addition to calculating hasi values. When signing, the private key generated by DSA must be paired with DSS1 (i.e. SHA1). For RSA-generated private keys, any message digest algorithm can be used.
# Message Digest Algorithm application Example
# using the SHA1 algorithm to compute the file.txt value of the file, output to stdout
$ openssl dgst-sha1 file.txt
# using the SHA1 algorithm to compute the file File.txt's Hudson value, Output to file Digest.txt
$ openssl sha1-out digest.txt file.txt
# with DSS1 (SHA1) algorithm for file file.txt signature, output to file Dsasign.bin
# The private key for the signature must be generated for the DSA algorithm, saved in file Dsakey.pem
$ openssl dgst-dss1-sign dsakey.pem-out dsasign.bin file.txt
# with DSS1 The algorithm validates the File.txt digital signature dsasign.bin,
# authenticated private key to the file generated by the DSA algorithm DSAKEY.PEM
$ openssl dgst-dss1-prverify Dsakey.pem- Signature Dsasign.bin file.txt
# with SHA1 algorithm for file file.txt signature, output to file Rsasign.bin
# signed Private Key is the file generated by the RSA algorithm RSAPRIVATE.PEM
$ openssl sha1-sign rsaprivate.pem-out rsasign.bin file.txt
# The file.txt digital signature Rsasign.bin is validated with the SHA1 algorithm, and the
# authenticated public key is generated for the RSA algorithm RSAPUBLIC.PEM
$ openssl sha1-verify Rsapublic.pem- Signature Rsasign.bin file.txt