0

I'm encrypting a string using this function;

$encrypted_body = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, utf8_encode($body), MCRYPT_MODE_CBC, $iv); 
//Encrypting using MCRYPT_RIJNDAEL_256 algorithm  

I then get my encrypted string.

What i need to do next is convert this string into a Byte Array. How do I do this? I've played with the pack/unpack features but am not having any luck!

Any help would be great.

Thanks in Advance!

0

1 Answer 1

1

PHP does not have byte arrays. What other languages call byte arrays are just a string of bytes one after the other, which can be accessed by their offset. PHP strings in fact do the same thing:

$encrypted_body[0]  ->  first byte
$encrypted_body[1]  ->  second byte
$encrypted_body[n]  ->  n+1th byte

So, just use PHP strings for the same purpose.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.