sodium_hex2bin

(PHP 7 >= 7.2.0, PHP 8)

sodium_hex2binDecodes a hexadecimally encoded binary string

说明

sodium_hex2bin(#[\SensitiveParameter] string $string, string $ignore = ""): string

Decodes a hexadecimally encoded binary string.

Like sodium_bin2hex(), sodium_hex2bin() is resistant to side-channel attacks while hex2bin() is not.

参数

string

Hexadecimal representation of data.

ignore

Optional string argument for characters to ignore.

返回值

Returns the binary representation of the given string data.

添加备注

用户贡献的备注 1 note

up
0
o-ren-shi at o2 dot pl
9 days ago
For some very, very weird reason, if you pass an invalid argument to this function:

<?php $cfg['blowfish_secret'] = sodium_hex2bin('f16ce59f45714194371b48dZGBmq4sRDUFy99glKIlKjlxaB76luP64d6fb13851'); ?>

then you'll get "Fatal error: Uncaught Error: Call to undefined function sodium_hex2bin()" error instead of any error that would tell you that your argument is invalid.

I still keep wondering why this isn't intercepted internally and how can PHP find one of its internal functions undefined only due to the wrong argument developer calls them with.
To Top