现在,我有一个由java MD5withRSA加密的字符串,我想通过ruby验证它。我有他的公钥,但我无法验证。
def verify?(encrypted_string, origin_string)
public_key = OpenSSL::PKey::RSA.new(File.read(PUBLIC_KEY))
public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(encrypted_string), origin_string)
end
我不知道MD5withRSA是如何工作的,我试图使用OpenSSL :: Digest :: MD5.new来验证它......
def verify?(encrypted_string, origin_string)
public_key = OpenSSL::PKey::RSA.new(File.read(PUBLIC_KEY))
public_key.verify(OpenSSL::Digest::MD5.new, Base64.decode64(encrypted_string), origin_string)
end
答案 0 :(得分:0)
rsa = OpenSSL::PKey::RSA.new(publick_key)
rsa.verify('md5', Base64.decode64(sign), rsa_string.force_encoding("utf-8"))