I wouldn't expect that this API will be removed within next 5 years.
If, unfortunately, the API is removed, apart from rewriting, are there any other ways to retain the old functionality?
there are literally no reasons to stick with old cryptography APIs when it is possible to switch to CNG. CNG provides same functionality and adds even more functionality. In the past, backward compatibility with older clients was a concern, but in 2023, it is no longer an excuse. CNG is supported down to Windows Vista, which is no longer supported.