Get a Provider : Provider « Security « Java Tutorial






import java.security.Key;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;

import javax.crypto.Cipher;

public final class MainClass {
  String providerName = "Rot13Provider";

  String algorithmName = "ROT13";

  public static void main(String[] args) throws Exception {
    Provider p = Security.getProvider("Rot13Provider");
    System.out.println("Provider name: " + p.getName());
    System.out.println("Provider version: " + p.getVersion());
    System.out.println("Provider information: " + p.getInfo());

    Cipher cipher = Cipher.getInstance("ROT13", "Rot13Provider");
    System.out.println("Cipher: " + cipher.getAlgorithm());
    String testString = "This is a test!";
    cipher.init(Cipher.ENCRYPT_MODE, (Key) null, new SecureRandom());
    byte[] b1 = cipher.doFinal(testString.getBytes());
    cipher.init(Cipher.DECRYPT_MODE, (Key) null, new SecureRandom());
    byte[] b2 = cipher.doFinal(b1);
    System.out.println("Decrypted data as a String: " + new String(b2));
  }
}








36.34.Provider
36.34.1.Security.getProviders()
36.34.2.Listing All Available Cryptographic Services
36.34.3.Return the available implementations for a service type
36.34.4.Get cryptographic security providers
36.34.5.Get a Provider
36.34.6.List the available capabilities for ciphers, key agreement, macs, message digests, signatures and other objects in the BC provider.
36.34.7.Get Provider Info
36.34.8.extends java.security.Provider
36.34.9.extends Provider