@@ -258,7 +258,7 @@ public static string RSAEncrypt(string publicKey, string srcString)
258258 Check . Argument . IsNotEmpty ( publicKey , nameof ( publicKey ) ) ;
259259 Check . Argument . IsNotEmpty ( srcString , nameof ( srcString ) ) ;
260260
261- using ( RSA rsa = RSA . Create ( 2048 ) )
261+ using ( RSA rsa = RSA . Create ( ) )
262262 {
263263 rsa . FromJsonString ( publicKey ) ;
264264 byte [ ] encryptBytes = rsa . Encrypt ( Encoding . UTF8 . GetBytes ( srcString ) , RSAEncryptionPadding . OaepSHA512 ) ;
@@ -276,7 +276,7 @@ public static string RSADecrypt(string privateKey, string srcString)
276276 Check . Argument . IsNotEmpty ( privateKey , nameof ( privateKey ) ) ;
277277 Check . Argument . IsNotEmpty ( srcString , nameof ( srcString ) ) ;
278278
279- using ( RSA rsa = RSA . Create ( 2048 ) )
279+ using ( RSA rsa = RSA . Create ( ) )
280280 {
281281 rsa . FromJsonString ( privateKey ) ;
282282 byte [ ] srcBytes = srcString . ToBytes ( ) ;
@@ -286,11 +286,11 @@ public static string RSADecrypt(string privateKey, string srcString)
286286 }
287287
288288 /// <summary>
289- /// RSA Instance
289+ /// RSA from json string
290290 /// </summary>
291- /// <param name="rsaKey"></param>
291+ /// <param name="rsaKey">rsa json string </param>
292292 /// <returns></returns>
293- public static RSA RSAInstance ( string rsaKey )
293+ public static RSA RSAFromString ( string rsaKey )
294294 {
295295 Check . Argument . IsNotEmpty ( rsaKey , nameof ( rsaKey ) ) ;
296296 RSA rsa = RSA . Create ( ) ;
@@ -302,12 +302,12 @@ public static RSA RSAInstance(string rsaKey)
302302 /// <summary>
303303 /// Create an RSA key
304304 /// </summary>
305+ /// <param name="keySizeInBits">the default size is 2048</param>
305306 /// <returns></returns>
306- public static RSAKey CreateRsaKey ( )
307+ public static RSAKey CreateRsaKey ( RsaSize rsaSize = RsaSize . R2048 )
307308 {
308- using ( RSA rsa = RSA . Create ( 2048 ) )
309+ using ( RSA rsa = RSA . Create ( ( int ) rsaSize ) )
309310 {
310-
311311 string publicKey = rsa . ToJsonString ( false ) ;
312312 string privateKey = rsa . ToJsonString ( true ) ;
313313
0 commit comments