OneSM3 PHP Library: Installation, Usage, and Performance Comparison with OpenSSL

This article introduces the OneSM3 PHP library for the SM3 cryptographic hash, provides Composer installation steps, usage examples for string and file signing, and presents performance benchmark results comparing it with OpenSSL and another PHP SM3 implementation.

php Courses
php Courses
php Courses
OneSM3 PHP Library: Installation, Usage, and Performance Comparison with OpenSSL

OneSM3 is a PHP library implementing the SM3 cryptographic hash algorithm, with source code hosted on GitHub.

Code repository : https://github.com/lizhichao/sm Installation : Use Composer to add the package. composer require lizhichao/one-sm Usage examples:

require __DIR__ . '/vendor/autoload.php';
// String signature
echo \OneSm\Sm3::sign('abc') . PHP_EOL;
echo \OneSm\Sm3::sign(str_repeat("adfas哈哈哈", 100)) . PHP_EOL;
// File signature
echo \OneSm\Sm3::signFile(__FILE__) . PHP_EOL;

Performance testing compares the library against OpenSSL and another PHP SM3 implementation (SM3-PHP). Run the benchmark script: php bench.php The benchmark results show identical hash values for OpenSSL and one-sm3, while SM3-PHP produces a different hash; execution times are approximately 4.76 ms for OpenSSL, 5.53 ms for one-sm3, and 708 ms for SM3-PHP.

For the full source and detailed results, see the original article linked below.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PHPHashOpenSSLcryptographySM3
php Courses
Written by

php Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.