1

What is the PHP equivalent for the following C# code

Encoding.ASCII.GetBytes(vstrEncryptionKey.ToCharArray())

where vstrEncryptionKey is a variable?

gideon
  • 19,329
  • 11
  • 72
  • 113
Ranju
  • 147
  • 2
  • 4
  • 10

1 Answers1

0

Use the ord function (http://php.net/ord) and the mb_strlen function http://php.net/manual/en/function.mb-strlen.php)

<?php
$var = $vstrEncryptionKey;

for($i = 0; $i < mb_strlen($var, 'ASCII'); $i++)
{
   echo ord($var[$i]);
}
?>

This is modified code from the answer given in How do I get the byte values of a string in PHP?

Community
  • 1
  • 1
Intermernet
  • 18,604
  • 4
  • 49
  • 61