Tag: pki

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

我想加密一个字符串,以便最终用户可以validation它是否由我加密,但是他们不能自己加密它。 例如,我有一个私钥’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 […]