views:

67

answers:

1

I'm trying to convert a encrypt/decrypt function from VB to PHP, but I'm having problems with this part:

Format$(Hex$(AscSrc), ″@@″)`

Is there a way to convert that to PHP? I couldn't find how to convert the @ symbol.

+1  A: 

I'm not familiar to VB, but it looks like its doing a str_pad(dechex(ord($AscSrc[0])), 2, '0', STR_PAD_LEFT); or simply bin2hex($AscSrc[0]);.

Maybe you can optimize this code, sinse PHP has the bin2hex(); function which instantly convert the entire string into a sequence of 2-digit hexadecimals. You can put a space between them with preg_replace('/../' '\0 ', bin2hex($AscSrc)); if thats the case.

Havenard