How can I get the signature of a string using SHA1withRSA
if I already have the Private Key as byte[]
or String
?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I guess what you say is you know the key pair before hand and want to sign/verify with that.
Please see the following code.
Here you need to change the method getKeyPair() to supply your known key pair. You may load it from a java key store [JKS].
You can't just have an arbitrary byte array either as your public key or private key. They should be generated in relation.
You first must create a public key from array of bytes
and after using the publicKey to encrypt
Now only who have the privateKey can read your data
@rczajka: a publicKey is a key. You can use it to sign somethig that only the owner (that have the privateKey) can read.