I'm trying to feed the output of roByteArray.FromBase64String() directly into roEVPCipher.Process(), but Process() returns invalid sometimes. To make it work consistently I have to run cryptext through ToHexString() and FromHexString() before hitting Process(). The problem comes and go as the length of cryptext changes. It's repeatable but I cannot discern any pattern. For all cryptexts that have a problem, ba and ba2 appear to be identical, yet ba cannot be decrypted while ba2 decrypts ok.
Does anyone have any idea what's going on here?
Does not work:
key = "12345678901234567890123456789012"
iv = "1234567890123456"
cryptext = "a2Lv5D+dKbcd5Al6Zb8Fqk99hMxH86gDJ6bHoroaK5c="
dcrypto = CreateObject("roEVPCipher")
dcrypto.Setup(false,"bf",key,iv,1)
ba = CreateObject("roByteArray")
ba.FromBase64String(cryptext)
print dcrypto.Process(ba).ToAsciiString()
Works Ok - Extra conversion using .ToHexString():
key = "12345678901234567890123456789012"
iv = "1234567890123456"
cryptext = "a2Lv5D+dKbcd5Al6Zb8Fqk99hMxH86gDJ6bHoroaK5c="
dcrypto = CreateObject("roEVPCipher")
dcrypto.Setup(false,"bf",key,iv,1)
ba = CreateObject("roByteArray")
ba.FromBase64String(cryptext)
temp = ba.ToHexString()
ba2 = CreateObject("roByteArray")
ba2.FromHexString(temp)
print dcrypto.Process(ba2).ToAsciiString()
Works Ok - Same as 1st example, but different cryptext length:
key = "12345678901234567890123456789012"
iv = "1234567890123456"
cryptext = "a2Lv5D+dKbcd5Al6Zb8Fqk99hMxH86gDj3Ur0ytpBJg9VAinHfW44GQJywUGmywlbd+5/s7eFcz+1ABpO32n/lQ9ByM4/jXH"
dcrypto = CreateObject("roEVPCipher")
dcrypto.Setup(false,"bf",key,iv,1)
ba = CreateObject("roByteArray")
ba.FromBase64String(cryptext)
print dcrypto.Process(ba).ToAsciiString()
www.InstantTvChannel.com / www.InstantSubtitles.com - 717-441-4386 - Build a Roku SDK channel in 15 minutes! Easily and inexpensively generate subtitles!