VB.NETの最近のブログ記事
MD5やSHA1のハッシュ値を取得するには、名前空間System.Security.Cryptographyの以下のクラスを利用します。
MD5: MD5CryptoServiceProvider クラス
SHA1:SHA1CryptoServiceProvider クラス
http://msdn.microsoft.com/ja-jp/library/system.security.cryptography.md5cryptoserviceprovider(VS.80).aspx
SHA1の場合は、
MD5: MD5CryptoServiceProvider クラス
SHA1:SHA1CryptoServiceProvider クラス
Dim str As String = "TEST"
Dim md5 As New MD5CryptoServiceProvider
Dim sha1 As New SHA1CryptoServiceProvider
Dim byteValue() As Byte = Encoding.UTF8.GetBytes(str)
Dim hashValue() As Byte = md5.ComputeHash(byteValue)
Dim result As StringBuilder = New StringBuilder()
Dim b As Byte
For Each b In hashValue
result.Append(b.ToString("x2"))
Next
MessageBox.Show(result.ToString, "ハッシュ結果", MessageBoxButtons.OK)
MD5CryptoServiceProvider クラスDim md5 As New MD5CryptoServiceProvider
Dim sha1 As New SHA1CryptoServiceProvider
Dim byteValue() As Byte = Encoding.UTF8.GetBytes(str)
Dim hashValue() As Byte = md5.ComputeHash(byteValue)
Dim result As StringBuilder = New StringBuilder()
Dim b As Byte
For Each b In hashValue
result.Append(b.ToString("x2"))
Next
MessageBox.Show(result.ToString, "ハッシュ結果", MessageBoxButtons.OK)
http://msdn.microsoft.com/ja-jp/library/system.security.cryptography.md5cryptoserviceprovider(VS.80).aspx
SHA1の場合は、
VB.NET(VB2005)アプリからのHttpアクセスを行うには、System.NET名前空間のWebClientクラスを用います。
http://msdn.microsoft.com/ja-jp/library/system.net.webclient(VS.80).aspx
Sub Main()
Dim wc As System.Net.WebClient = New System.Net.WebClient()
Dim st As System.IO.Stream = wc.OpenRead("http://xxxx/test/default.aspx")
st.Close()
End Sub
WebClient クラスDim wc As System.Net.WebClient = New System.Net.WebClient()
Dim st As System.IO.Stream = wc.OpenRead("http://xxxx/test/default.aspx")
st.Close()
End Sub
http://msdn.microsoft.com/ja-jp/library/system.net.webclient(VS.80).aspx
