Re: Unable to decrypt - WeOnlyDo Discussion board

Re: Unable to decrypt (General questions)

by woddrazen, Thursday, May 31, 2007, 20:04 (6390 days ago) @ Chris

Hi Chris,


Please try something like this (it worked for me):

[code]
Dim iv, key
Set key = CreateObject( WeOnlyDo.MemBlob.1 )
Set iv = CreateObject( WeOnlyDo.MemBlob.1 )

Sub CreateKeyIV(key, keylen, iv, ivlen)
Dim c,addoldmd5, needmore, inblob1, outblob1, keydata, old
Set c = WScript.CreateObject( WeOnlyDo.wodCryptCom.1 ) '...Com is missing in you sample
Set inblob1 = CreateObject( WeOnlyDo.MemBlob.1 )
Set outblob1 = CreateObject( WeOnlyDo.MemBlob.1 )

addoldmd5 = False
hexkey = key.ToHex

key.FromHex
iv.FromHex

needmore = True

Do

c.Type = 100

If addoldmd5 Then keydata = oldmd5
keydata = keydata & hexkey
inblob1.FromHex(keydata)
c.Digest inblob1, outblob1

addoldmd5 = True
oldmd5 = outblob1.ToHex

If Len(key.ToHex) / 2 < keylen Then
old = key.ToHex
old = old & oldmd5
key.FromHex old
Else
If Len(iv.ToHex) / 2 < ivlen Then
old = iv.ToHex
old = old & oldmd5
iv.FromHex old
Else
needmore = False
End If
End If
Loop While needmore
End Sub


Dim Crypt1, indata, outdata

Set Crypt1 = WScript.CreateObject( WeOnlyDo.wodCryptCom.1 ) '...Com is missing in you sample
Set indata = CreateObject( WeOnlyDo.MemBlob.1 )
Set outdata = CreateObject( WeOnlyDo.MemBlob.1 )

Crypt1.Type = 4
Crypt1.Mode = 1
Crypt1.Optimized = False
Crypt1.Padding = 3

key.Text = 12345678901234561234567890123456
CreateKeyIV key, Crypt1.KeySize, iv, Crypt1.BlockSize
Crypt1.SecretKey = key
Crypt1.InitVector = iv

indata.FromFile c: est.out

Crypt1.Decrypt indata, outdata

Wscript.Echo outdata.Text
[/code]

Let us know how it goes.


Regards,
Drazen


Complete thread: