Skip to content

Commit a1596e5

Browse files
committed
Merge pull request #17 from jbochi/patch-2
Add example with AES 128 CBC with IV
2 parents 1782c00 + 8ee37b7 commit a1596e5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ Synopsis
158158
ngx.say("AES 256 CBC (SHA-512, salted) Encrypted HEX: ", str.to_hex(encrypted))
159159
ngx.say("AES 256 CBC (SHA-512, salted) Decrypted: ",
160160
aes_256_cbc_sha512x5:decrypt(encrypted))
161+
162+
local aes = require "resty.aes"
163+
local str = require "resty.string"
164+
local aes_128_cbc_with_iv = assert(aes:new("1234567890123456",
165+
nil, aes.cipher(128,"cbc"), {iv="1234567890123456"}))
166+
-- AES 128 CBC with IV and no SALT
167+
local encrypted = aes_128_cbc_with_iv:encrypt("Really secret message!")
168+
ngx.say("AES 128 CBC (WITH IV) Encrypted HEX: ", str.to_hex(encrypted))
169+
ngx.say("AES 128 CBC (WITH IV) Decrypted: ",
170+
aes_128_cbc_with_iv:decrypt(encrypted))
161171
```
162172

163173
[Back to TOC](#table-of-contents)

0 commit comments

Comments
 (0)