ruby 實現java中的aes 加密解密
阿新 • • 發佈:2018-03-20
abcde class hwm nbsp crypt 實現 () cbc sad
def
aes_encrypt()
cipher = OpenSSL::Cipher::AES.new(128, :CBC)
cipher.encrypt cipher.key = "quck7295abvdefgh" data= ‘sssssdsadkjak‘ cipher.iv = "abcdefghhigk" encrypted = cipher.update(data) + cipher.final Base64.strict_encode64(encrypted)end
def
aes_dicrypt()
data = ‘hWmnsBO1buB1==‘
cipher = OpenSSL::Cipher.new(‘aes-128-cbc‘)
cipher.key = "quck7295abvdefgh"
cipher.iv = "abcdefghhigk"
cipher.decrypt
plain_text = ""
plain_text << cipher.update(Base64.decode64(data))
plain_text << cipher.final
return plain_text
end
ruby 實現java中的aes 加密解密