
131
zeroes). The IV will typically contain arbitrary characters and be in the form of an roByteArray, though it can also be
a string.
• Encrypt(key As Object, plaintext As Object) As roByteArray: Uses the specified key to encrypt
the plaintext parameter, which can be passed as either a string or an roByteArray.
• Decrypt(key As Object, cipher_text As Object) As roByteArray: Uses the specified key to
decrypt cipher text, which should be passed as an roByteArray. Because the cipher text is encrypted, it can contain
any character.
Example:
' This is Case#4 from RFC3602
key = CreateObject("roByteArray")
iv = CreateObject("roByteArray")
plain = CreateObject("roByteArray")
key.FromHexString("56e47a38c5598974bc46903dba290349")
iv.FromHexString("8ce82eefbea0da3c44699ed7db51b7d9")
plain.FromHexString("a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1
c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf")
c = CreateObject("roBlockCipher", { mode: "aes-128-cbc" })
c.SetIV(iv)
crypt = c.Encrypt(key, plain)
result = crypt.ToHexString()
expected =
UCase("c30e32ffedc0774e6aff6af0869f71aa0f3af07a9a31a9c684db207eb0ef8e4e35907aa632c3ffdf86
8bb7b29d3d46ad83ce9f9a102ee99d49a53e87f4c3da55")
' Decrypt example to recover the encrypted data
c.SetIV(iv)
roundtrip = c.Decrypt(key, crypt)
Kommentare zu diesen Handbüchern