Can anyone help me with converting the following Python script to PHP?
data = json.dumps({'text': 'Hello world'})
content_sha256 = base64.b64encode(SHA256.new(data).digest())
The value of content_sha256 should be
oWVxV3hhr8+LfVEYkv57XxW2R1wdhLsrfu3REAzmS7k=
I have tried to use the base64_encode function, and will only get the desired result if I use the string:
$data_string = "{\"text\": \"Hello world\"}";
base64_encode(hash("sha256", $data_string, true));
but I want to get the desired result by using and array, not a quote-escaped string...