File tree Expand file tree Collapse file tree
core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .baeldung .cipher ;
2+
3+ import java .security .Provider ;
4+ import java .security .Security ;
5+ import java .util .Arrays ;
6+ import java .util .List ;
7+ import java .util .stream .Collectors ;
8+
9+ public class AvailableCiphers {
10+ public static void main (String [] args ) {
11+ printAllCiphers ();
12+ printCompatibleCiphers ();
13+ }
14+
15+ private static void printAllCiphers () {
16+ for (Provider provider : Security .getProviders ()) {
17+ for (Provider .Service service : provider .getServices ()) {
18+ System .out .println (service .getAlgorithm ());
19+ }
20+ }
21+ }
22+
23+ private static void printCompatibleCiphers () {
24+ List <String > algorithms = Arrays .stream (Security .getProviders ())
25+ .flatMap (provider -> provider .getServices ().stream ())
26+ .filter (service -> "Cipher" .equals (service .getType ()))
27+ .map (Provider .Service ::getAlgorithm )
28+ .collect (Collectors .toList ());
29+
30+ algorithms .forEach (System .out ::println );
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments