The SM3 password hashing algorithm is a hash algorithm similar to SHA-256, which belongs to the Chinese national standard. This library only contains a Fortran interface SM3
of GmSSL and its usage examples.
Based on interest, I learned about hashing algorithms, and I made some attempts, but Fortran lacks unsigned integers, it is not suitable to implement hashing algorithms, and can only rely on C Binding.
Among open source code, GmSSL is popular for its high quality of code completion. Introducing GmSSL code entirely using fpm will cause compilation to fail,
The selected part of this library introduces GmSSL/SM3 algorithm code as a dependency of SM3-Fortran
. The Fortran Standard Library already has the Hash algorithm,
the introduction of SM3-Fortran
has the following implications:
- SM3 is a Chinese national standard hash algorithm, GmSSL is a Chinese-led project with Chinese feelings;
- SM3 security comparable to SHA-256;
SM3-Fortran
is a lightweight interface package, Fortran-Stdlib/Hash is relatively larger;SM3-Fortran
only introduces the SM3 algorithm, providing a practical reference for Fortran Binding of other algorithms.
中文 | English
- Fortran-lang/fpm >= 0.7.0: for building packages and package distribution;
- GNU/GCC >= 9.4.0: for compiling C, Fortran code;
After downloading or cloning the repository locally, you can use fpm to compile the code:
cd SM3-Fortran
fpm run --example demo # Run the example demo
fpm build --profile release
fpm build --profile release --flag "-DSM3_SSE3" # Enable SSE3 optimization
It is also possible to add SM3-Fortran
to a self-built fpm project:
[dependencies]
SM3-Fortran = { git = "https://github.com/zoziha/SM3-Fortran" }
Refer to Chinese National Standard for learning SM3 algorithm and DEMO for using SM3-Fortran
.