Why are the RSA signatures I generate with openssl and golang different?

后端 未结 3 1138
猫巷女王i
猫巷女王i 2021-01-16 02:21

I use openssl command to sign the message \"Test.\", output with hexdump

# echo \"Test.\" | openssl rsautl -inkey privite.key -sign -hexdump
0000 - 09 1b ce          


        
3条回答
  •  佛祖请我去吃肉
    2021-01-16 02:30

    The echo command prints a string with a trailing newline (\n or 0a):

    > echo 'Test.' | hexdump -C
    00000000  54 65 73 74 2e 0a                                 |Test..|
    00000006
    

    So in your case, you're signing Test.\n the first time, and Test. the second time in your Go program. Use echo's -n switch to suppress the trailing newline:

    > echo -n 'Test.' | hexdump -C
    00000000  54 65 73 74 2e                                    |Test.|
    00000005
    

提交回复
热议问题