@@ -20,12 +20,22 @@ internal static void RegisterKey(string key)
2020 GlobalKey = key ;
2121 }
2222
23+ public static byte [ ] Encrypt ( string plaintext )
24+ {
25+ return Encrypt ( plaintext , null ) ;
26+ }
27+
2328 public static byte [ ] Encrypt ( string plaintext , string ? key = null )
2429 {
2530 var bytes = Encoding . UTF8 . GetBytes ( plaintext ) ;
2631 return Encrypt ( bytes , key ) ;
2732 }
2833
34+ public static byte [ ] Encrypt ( byte [ ] plaintext )
35+ {
36+ return Encrypt ( plaintext , null ) ;
37+ }
38+
2939 public static byte [ ] Encrypt ( byte [ ] plaintext , string ? key = null )
3040 {
3141 if ( plaintext . Length == 0 )
@@ -42,6 +52,11 @@ public static byte[] Encrypt(byte[] plaintext, string? key = null)
4252 return Arrays . Concatenate ( siv , cipher ) ;
4353 }
4454
55+ public static void Encrypt ( Stream input , Stream output )
56+ {
57+ Encrypt ( input , output , null ) ;
58+ }
59+
4560 public static void Encrypt ( Stream input , Stream output , string ? key = null )
4661 {
4762 ArgumentNullException . ThrowIfNull ( input ) ;
@@ -53,12 +68,22 @@ public static void Encrypt(Stream input, Stream output, string? key = null)
5368 output . Write ( encrypted , 0 , encrypted . Length ) ;
5469 }
5570
71+ public static string Decrypt ( byte [ ] ciphertext )
72+ {
73+ return Decrypt ( ciphertext , null ) ;
74+ }
75+
5676 public static string Decrypt ( byte [ ] ciphertext , string ? key = null )
5777 {
5878 var plain = DecryptToBytes ( ciphertext , key ) ;
5979 return Encoding . UTF8 . GetString ( plain ) ;
6080 }
6181
82+ public static byte [ ] DecryptToBytes ( byte [ ] ciphertext )
83+ {
84+ return DecryptToBytes ( ciphertext , null ) ;
85+ }
86+
6287 public static byte [ ] DecryptToBytes ( byte [ ] ciphertext , string ? key = null )
6388 {
6489 var keyBytes = GetKeyBytes ( key ) ;
@@ -86,6 +111,11 @@ public static byte[] DecryptToBytes(byte[] ciphertext, string? key = null)
86111 return plain ;
87112 }
88113
114+ public static void Decrypt ( Stream input , Stream output )
115+ {
116+ Decrypt ( input , output , null ) ;
117+ }
118+
89119 public static void Decrypt ( Stream input , Stream output , string ? key = null )
90120 {
91121 ArgumentNullException . ThrowIfNull ( input ) ;
0 commit comments