vb.net - PHP decryption of VB data -


i taking on task wrote library years ago. library vb , asp.

i'm working in php need decrypt load of strings have been stored in database after being encrypted in vb:

 public function encrypt(byval mystring object) string     if isdbnull(mystring) or isnothing(mystring)         return string.empty     else         if mystring.length = 0             return ""         else             cryptdes3.key = cryptmd5hash.computehash(asciiencoding.ascii.getbytes(mykey))             cryptdes3.mode = ciphermode.ecb             dim desdencrypt icryptotransform = cryptdes3.createencryptor()             dim myasciiencoding asciiencoding = new asciiencoding()             dim buff() byte = asciiencoding.ascii.getbytes(mystring)             return convert.tobase64string(desdencrypt.transformfinalblock(buff, 0, buff.length))         end if      end if  end function 

the appropriate decryption function in vb like:

public function decrypt(byval mystring object) string     try         if isdbnull(mystring) or isnothing(mystring)             return string.empty         else             if mystring.length = 0                 return ""             else                 cryptdes3.key = cryptmd5hash.computehash(asciiencoding.ascii.getbytes(mykey))                 cryptdes3.mode = ciphermode.ecb                 dim desdencrypt icryptotransform = cryptdes3.createdecryptor()                 dim buff() byte = convert.frombase64string(mystring)                 decrypt = asciiencoding.ascii.getstring(desdencrypt.transformfinalblock(buff, 0, buff.length))             end if         end if     catch ex exception         return "db error"     end try  end function 

can offer idea how decrypt strings in php? i've tried sorts of ideas suggested on here none of them produce actual data i'm supposed get!

(posted on behalf of op).

i solved problem considering mark's suggestion on page. mark. in case else struggles:

$data = "my_string"; $secret  = "my_secret"; $key = md5(utf8_encode($secret), true); $key .= substr($key, 0, 8); $data = base64_decode($data); $data = mcrypt_decrypt('tripledes', $key, $data, 'ecb'); $block = mcrypt_get_block_size('tripledes', 'ecb'); $len = strlen($data); $pad = ord($data[$len-1]); echo "decrypted string is: " . substr($data, 0, strlen($data) - $pad); 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -