VB.NET MD5ハッシュ値の取得
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の場合は、
トラックバック(0)
このブログ記事を参照しているブログ一覧: VB.NET MD5ハッシュ値の取得
このブログ記事に対するトラックバックURL: http://blog.e-slas.com/weblog/mt-tb.cgi/26
