From 8ee37b78af3f6b918bbd49d10870101bd1068b9f Mon Sep 17 00:00:00 2001 From: Juarez Bochi Date: Thu, 8 May 2014 10:29:33 -0300 Subject: [PATCH] Add example with AES 128 CBC with IV --- README.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.markdown b/README.markdown index 30bfe82..887684b 100644 --- a/README.markdown +++ b/README.markdown @@ -158,6 +158,16 @@ Synopsis ngx.say("AES 256 CBC (SHA-512, salted) Encrypted HEX: ", str.to_hex(encrypted)) ngx.say("AES 256 CBC (SHA-512, salted) Decrypted: ", aes_256_cbc_sha512x5:decrypt(encrypted)) + + local aes = require "resty.aes" + local str = require "resty.string" + local aes_128_cbc_with_iv = assert(aes:new("1234567890123456", + nil, aes.cipher(128,"cbc"), {iv="1234567890123456"})) + -- AES 128 CBC with IV and no SALT + local encrypted = aes_128_cbc_with_iv:encrypt("Really secret message!") + ngx.say("AES 128 CBC (WITH IV) Encrypted HEX: ", str.to_hex(encrypted)) + ngx.say("AES 128 CBC (WITH IV) Decrypted: ", + aes_128_cbc_with_iv:decrypt(encrypted)) ``` [Back to TOC](#table-of-contents)