我想加密一个字符串,这样最终用户可以验证它是由我加密的,但他们不能自己加密。
例如,我有一个私钥“private”,一个公钥“public”,一条消息“hello world”,我想做类似的事情:
private_key = 'private'
public_key = 'public'
message = 'hello world'
encrypted_value = Crypto.encrypt(message, private_key)
# encrypted_value is now 'd92a01df241a3'
is_verified = Crypto.verify(message, public_key)
# given just the public key and the message, is_verified will
# be able to tell whether it's accurate
# note that the encrypted_value cannot be generated by just the public_key
# but it can be verified by the public_key
我是一名优秀的程序员,十分优秀!