File tree Expand file tree Collapse file tree 12 files changed +97
-46
lines changed
csharp/System.Security.Cryptography
visualbasic/VS_Snippets_CLR_Classic
classic SHA384 Example/VB
classic SHA384Managed Example/VB
classic SHA512 Example/VB
classic SHA512Managed Example/VB Expand file tree Collapse file tree 12 files changed +97
-46
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,11 @@ protected void Method()
1212// <Snippet1>
1313byte [ ] data = new byte [ DATA_SIZE ] ;
1414byte [ ] result ;
15- SHA384 shaM = new SHA384Managed ( ) ;
16- result = shaM . ComputeHash ( data ) ;
15+
16+ using ( SHA384 sha384 = SHA384 . Create ( ) )
17+ {
18+ result = sha384 . ComputeHash ( data ) ;
19+ }
1720// </Snippet1>
1821 }
1922}
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ protected void Method()
1313byte [ ] data = new byte [ DATA_SIZE ] ;
1414byte [ ] result ;
1515
16- SHA384 shaM = new SHA384Managed ( ) ;
17- result = shaM . ComputeHash ( data ) ;
16+ using ( SHA384 shaM = new SHA384Managed ( ) )
17+ {
18+ result = shaM . ComputeHash ( data ) ;
19+ }
1820// </Snippet1>
1921 }
2022}
Original file line number Diff line number Diff line change @@ -12,8 +12,11 @@ protected void Method()
1212// <Snippet1>
1313byte [ ] data = new byte [ DATA_SIZE ] ;
1414byte [ ] result ;
15- SHA512 shaM = new SHA512Managed ( ) ;
16- result = shaM . ComputeHash ( data ) ;
15+
16+ using ( SHA512 sha512 = SHA512 . Create ( ) )
17+ {
18+ result = sha512 . ComputeHash ( data ) ;
19+ }
1720// </Snippet1>
1821 }
1922}
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ protected void Method()
1313byte [ ] data = new byte [ DATA_SIZE ] ;
1414byte [ ] result ;
1515
16- SHA512 shaM = new SHA512Managed ( ) ;
17- result = shaM . ComputeHash ( data ) ;
16+ using ( SHA512 shaM = new SHA512Managed ( ) )
17+ {
18+ result = shaM . ComputeHash ( data ) ;
19+ }
1820// </Snippet1>
1921 }
2022}
Original file line number Diff line number Diff line change 22Imports System.ComponentModel
33Imports System.Security.Cryptography
44
5- Public Class Sample
6- Protected DATA_SIZE As Integer = 1024
7-
8- Protected Sub Method ()
5+ Public Module Sample
6+ Private DATA_SIZE As Integer = 1024
7+
8+ Public Sub Main ()
99' <Snippet1>
10- Dim data(DATA_SIZE) As Byte
11- Dim result() As Byte
12- Dim shaM As New SHA384Managed()
13- result = shaM.ComputeHash(data)
10+ Dim data(DATA_SIZE) As Byte
11+ Dim result() As Byte
12+
13+ Using sha384 As SHA384 = SHA384.Create()
14+ result = sha384.ComputeHash(data)
15+ End Using
1416' </Snippet1>
1517 End Sub
16- End Class
18+ End Module
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <RootNamespace >vb</RootNamespace >
6+ <TargetFramework >net6.0</TargetFramework >
7+ </PropertyGroup >
8+
9+ </Project >
Original file line number Diff line number Diff line change 22Imports System.ComponentModel
33Imports System.Security.Cryptography
44
5- Public Class Sample
6- Protected DATA_SIZE As Integer = 1024
7-
8- Protected Sub Method ()
5+ Public Module Sample
6+ Private DATA_SIZE As Integer = 1024
7+
8+ Public Sub Main ()
99' <Snippet1>
10- Dim data(DATA_SIZE) As Byte
11- Dim result() As Byte
12-
13- Dim shaM As New SHA384Managed( )
14- result = shaM.ComputeHash(data)
10+ Dim data(DATA_SIZE) As Byte
11+ Dim result() As Byte
12+ Using shaM As New SHA384Managed()
13+ result = shaM.ComputeHash(data )
14+ End Using
1515' </Snippet1>
1616 End Sub
17- End Class
17+ End Module
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <RootNamespace >vb</RootNamespace >
6+ <TargetFramework >net6.0</TargetFramework >
7+ </PropertyGroup >
8+
9+ </Project >
Original file line number Diff line number Diff line change 22Imports System.ComponentModel
33Imports System.Security.Cryptography
44
5- Public Class Sample
6- Protected DATA_SIZE As Integer = 1024
7-
8- Protected Sub Method ()
5+ Public Module Sample
6+ Private DATA_SIZE As Integer = 1024
7+
8+ Public Sub Main ()
99' <Snippet1>
10- Dim data(DATA_SIZE) As Byte
11- Dim result() As Byte
12- Dim shaM As New SHA512Managed()
13- result = shaM.ComputeHash(data)
10+ Dim data(DATA_SIZE) As Byte
11+ Dim result() As Byte
12+
13+ Using sha512 As SHA512 = SHA512.Create()
14+ result = sha512.ComputeHash(data)
15+ End Using
1416' </Snippet1>
1517 End Sub
16- End Class
18+ End Module
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <RootNamespace >vb</RootNamespace >
6+ <TargetFramework >net6.0</TargetFramework >
7+ </PropertyGroup >
8+
9+ </Project >
You can’t perform that action at this time.
0 commit comments