File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
test/NETCore.Encrypt.Tests Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ namespace NETCore.Encrypt.Tests
99 public class DES_Test
1010 {
1111 private readonly string _Key ;
12+ private readonly string _IV ;
1213
1314 public DES_Test ( )
1415 {
1516 _Key = EncryptProvider . CreateDesKey ( ) ;
17+ _IV = EncryptProvider . CreateDesIv ( ) ;
1618 }
1719
1820 [ Fact ( DisplayName = "DES ke test" ) ]
@@ -61,6 +63,23 @@ public void DES_Decryt_Success_Test()
6163 Assert . Equal ( srcString , decrypted ) ;
6264 }
6365
66+
67+ [ Fact ( DisplayName = "DES CBC mode decrypt success test" ) ]
68+ public void DES_CBCMode_Success_Test ( )
69+ {
70+ var srcString = "test DES encrypt" ;
71+
72+ //Ack
73+ var srsDatas = Encoding . UTF8 . GetBytes ( srcString ) ;
74+ var encrypted = EncryptProvider . DESEncrypt ( srsDatas , _Key , _IV ) ;
75+ var decrypted = EncryptProvider . DESDecrypt ( encrypted , _Key , _IV ) ;
76+ var decryptedStr = Encoding . UTF8 . GetString ( decrypted ) ;
77+ //Assert
78+ Assert . NotEmpty ( encrypted ) ;
79+ Assert . NotEmpty ( decrypted ) ;
80+ Assert . Equal ( srcString , decryptedStr ) ;
81+ }
82+
6483 [ Fact ( DisplayName = "DES decrypt with empty data test" ) ]
6584 public void DES_Decrypt_EmptyData_Fail_Test ( )
6685 {
You can’t perform that action at this time.
0 commit comments