Java Tutorial/Security/Bouncy Castle
Версия от 17:44, 31 мая 2010; (обсуждение)
Basic class to confirm the Bouncy Castle provider is installed.
import java.security.Security;
public class MainClass {
public static void main(String[] args) {
String providerName = "BC";
if (Security.getProvider(providerName) == null) {
System.out.println(providerName + " provider not installed");
} else {
System.out.println(providerName + " is installed.");
}
}
}
Basic demonstration of precedence
import javax.crypto.Cipher;
public class MainClass {
public static void main(String[] args) throws Exception {
Cipher cipher = Cipher.getInstance("Blowfish/ECB/NoPadding");
System.out.println(cipher.getProvider());
cipher = Cipher.getInstance("Blowfish/ECB/NoPadding", "BC");
System.out.println(cipher.getProvider());
}
}