I'm trying to initialize SHA256withRSA Signature object:
Signature signer = Signature.getInstance("SHA256withRSA");
But compiler generates NoSuchAlgorithmException
, but when I run this code:
import java.security.Signature;
public static void main(String[] args) throws IOException{
TreeSet<String> algorithms = new TreeSet<>();
for (Provider provider : Security.getProviders())
for (Provider.Service service : provider.getServices())
if (service.getType().equals("Signature"))
algorithms.add(service.getAlgorithm());
for (String algorithm : algorithms)
System.out.println(algorithm);
}
It creates output:
...
SHA256withECDSAinP1363Format
SHA256withRSA
SHA384withECDSA
...
What i'm doing wrong or what libraries should I include into project?