SQLの窓

2010年05月29日


VBScript : ネイティブ SHA1、MD5、SHA256 変換

Microsoft ドキュメント

HashedData Object (Windows)

関連する記事

VBScript : ネイティブ Base64 エンコード
Set CAPIUtil = CreateObject( "CAPICOM.Utilities" )
Set HashedData = CreateObject( "CAPICOM.HashedData" )
Set Stream = Wscript.CreateObject("ADODB.Stream")
Set StreamBin = Wscript.CreateObject("ADODB.Stream")

'***********************************************************
' データ準備4
'***********************************************************
Stream.Open
Stream.Charset = "shift_jis"
' shift_jis で入力文字を書き込む
Stream.WriteText "日本語表示OK"
Stream.Position = 0

' バイナリで開く
StreamBin.Open
StreamBin.Type = 1

' テキストをバイナリに変換
Stream.CopyTo StreamBin
Stream.Close

' 読み込みの為にデータポインタを先頭にセット
StreamBin.Position = 0

strBinaryString = CAPIUtil.ByteArrayToBinaryString( StreamBin.Read )

'***********************************************************
' SHA1 と MD5 と SHA256
'***********************************************************
' SHA1
HashedData.Algorithm = 0
HashedData.Hash(strBinaryString)

MsgBox(LCase(HashedData.Value))

' MD5
HashedData.Algorithm = 3
HashedData.Hash(strBinaryString)

MsgBox(LCase(HashedData.Value))

' SHA256
HashedData.Algorithm = 4
HashedData.Hash(strBinaryString)

MsgBox(LCase(HashedData.Value))




Set CAPIUtil = CreateObject( "CAPICOM.Utilities" )
Set HashedData = CreateObject( "CAPICOM.HashedData" )
Set Stream = Wscript.CreateObject("ADODB.Stream")
Set StreamBin = Wscript.CreateObject("ADODB.Stream")

'***********************************************************
' データ準備4
'***********************************************************
Stream.Open
Stream.Charset = "shift_jis"
' shift_jis で入力文字を書き込む
Stream.WriteText "日本語表示OK"
Stream.Position = 0

' バイナリで開く
StreamBin.Open
StreamBin.Type = 1

' テキストをバイナリに変換
Stream.CopyTo StreamBin
Stream.Close

' 読み込みの為にデータポインタを先頭にセット
StreamBin.Position = 0

strBinaryString = CAPIUtil.ByteArrayToBinaryString( StreamBin.Read )

Dim strTarget
'***********************************************************
' SHA512
' https://www.microsoft.com/ja-jp/download/details.aspx?id=3207
' https://docs.microsoft.com/ja-jp/windows/desktop/seccrypto/capicom-hash-algorithm
' C:\Windows\Syswow64\cscript.exe で実行
'***********************************************************
' SHA512
strTarget = strBinaryString
HashedData.Algorithm = 6
HashedData.Hash(strTarget)

MsgBox(LCase(HashedData.Value))





posted by lightbox at 2010-05-29 21:12 | VBS + オブジェクト | このブログの読者になる | 更新情報をチェックする
container 終わり



フリーフォントで簡単ロゴ作成
フリーフォントでボタン素材作成
フリーフォントで吹き出し画像作成
フリーフォントではんこ画像作成
ほぼ自由に利用できるフリーフォント
フリーフォントの書体見本とサンプル
画像を大きく見る為のウインドウを開くボタンの作成

CSS ドロップシャドウの参考デモ
イラストAC
ぱくたそ
写真素材 足成
フリーフォント一覧
utf8 文字ツール
右サイド 終わり
base 終わり