本文整理汇总了VB.NET中System.Security.Cryptography.RIPEMD160Managed类的典型用法代码示例。如果您正苦于以下问题:VB.NET RIPEMD160Managed类的具体用法?VB.NET RIPEMD160Managed怎么用?VB.NET RIPEMD160Managed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RIPEMD160Managed类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: HashDirectory
' 导入命名空间
Imports System.IO
Imports System.Security.Cryptography
Imports System.Windows.Forms
Public Class HashDirectory
Public Shared Sub Main(ByVal args() As String)
Dim directory As String
If args.Length < 1 Then
Dim fdb As New FolderBrowserDialog
Dim dr As DialogResult = fdb.ShowDialog()
If (dr = DialogResult.OK) Then
directory = fdb.SelectedPath
Else
Console.WriteLine("No directory selected")
Return
End If
Else
directory = args(0)
End If
Try
' Create a DirectoryInfo object representing the specified directory.
Dim dir As New DirectoryInfo(directory)
' Get the FileInfo objects for every file in the directory.
Dim files As FileInfo() = dir.GetFiles()
' Initialize a RIPE160 hash object.
Dim myRIPEMD160 As RIPEMD160 = RIPEMD160Managed.Create()
Dim hashValue() As Byte
' Compute and print the hash values for each file in directory.
Dim fInfo As FileInfo
For Each fInfo In files
' Create a fileStream for the file.
Dim fileStream As FileStream = fInfo.Open(FileMode.Open)
' Be sure it's positioned to the beginning of the stream.
fileStream.Position = 0
' Compute the hash of the fileStream.
hashValue = myRIPEMD160.ComputeHash(fileStream)
' Write the name of the file to the Console.
Console.Write(fInfo.Name + ": ")
' Write the hash value to the Console.
PrintByteArray(hashValue)
' Close the file.
fileStream.Close()
Next fInfo
Return
Catch DExc As DirectoryNotFoundException
Console.WriteLine("Error: The directory specified could not be found.")
Catch IOExc As IOException
Console.WriteLine("Error: A file in the directory could not be accessed.")
End Try
End Sub
' Print the byte array in a readable format.
Public Shared Sub PrintByteArray(ByVal array() As Byte)
Dim i As Integer
For i = 0 To array.Length - 1
Console.Write(String.Format("{0:X2}", array(i)))
If i Mod 4 = 3 Then
Console.Write(" ")
End If
Next i
Console.WriteLine()
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Security.Cryptography,代码行数:67,代码来源:RIPEMD160Managed
注:本文中的System.Security.Cryptography.RIPEMD160Managed类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论