gpt4 book ai didi

ruby - 如何在 Ruby 中使用 PKI(公钥/私钥)加密?

转载 作者:太空宇宙 更新时间:2023-11-03 17:06:43 25 4
gpt4 key购买 nike

<分区>

我想加密一个字符串,这样最终用户可以验证它是由我加密的,但他们不能自己加密。

例如,我有一个私钥“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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com