File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ using BenchmarkDotNet . Attributes ;
2+
3+ using Renci . SshNet . Security . Cryptography . Ciphers ;
4+ using Renci . SshNet . Security . Cryptography . Ciphers . Modes ;
5+
6+ namespace Renci . SshNet . Benchmarks . Security . Cryptography . Ciphers
7+ {
8+ [ MemoryDiagnoser ]
9+ public class TripleDesCipherBenchmarks
10+ {
11+ private readonly byte [ ] _key ;
12+ private readonly byte [ ] _iv ;
13+ private readonly byte [ ] _data ;
14+
15+ public TripleDesCipherBenchmarks ( )
16+ {
17+ _key = new byte [ 24 ] ;
18+ _iv = new byte [ 8 ] ;
19+ _data = new byte [ 32 * 1024 ] ;
20+
21+ Random random = new ( Seed : 12345 ) ;
22+ random . NextBytes ( _key ) ;
23+ random . NextBytes ( _iv ) ;
24+ random . NextBytes ( _data ) ;
25+ }
26+
27+ [ Benchmark ]
28+ public byte [ ] Encrypt_CBC ( )
29+ {
30+ return new TripleDesCipher ( _key , new CbcCipherMode ( _iv ) , null ) . Encrypt ( _data ) ;
31+ }
32+
33+ [ Benchmark ]
34+ public byte [ ] Decrypt_CBC ( )
35+ {
36+ return new TripleDesCipher ( _key , new CbcCipherMode ( _iv ) , null ) . Decrypt ( _data ) ;
37+ }
38+
39+ [ Benchmark ]
40+ public byte [ ] Encrypt_CFB ( )
41+ {
42+ return new TripleDesCipher ( _key , new CfbCipherMode ( _iv ) , null ) . Encrypt ( _data ) ;
43+ }
44+
45+ [ Benchmark ]
46+ public byte [ ] Decrypt_CFB ( )
47+ {
48+ return new TripleDesCipher ( _key , new CfbCipherMode ( _iv ) , null ) . Decrypt ( _data ) ;
49+ }
50+ }
51+ }
You can’t perform that action at this time.
0 commit comments