我要加密使用PKCS5padding 我的红宝石方法如下,如何在这里使用PKCS5Padding如何红宝石
def encrypt(raw_data,key)
cipher = OpenSSL::Cipher::AES.new(256, :ECB)
cipher.encrypt
cipher.key = key
encrypted_data = cipher.update(raw_data) + cipher.final
end
这里AES 256位ECB模式的数据的关键是OpenSSL的使用AES 256 ECB PKCS5Padding加密数据: :PKey :: RSA类型,投掷no implicit conversion of OpenSSL::PKey::RSA into String
异常
http://stackoverflow.com/a/36940796/3270427 – McNets
(raw_data)加密之前尝试Base64.encode64,我想你想加密的RSA密钥对不对? –
您可以使用cipher.random_key作为密钥,因为它不会接受字符串以外的其他格式 –