md5とSHA256でハッシュ化 - VB.NET
それぞれのクラスで定義されているComputeHash()
メソッドの引数と戻り値はバイト配列になっているため、注意
md5でハッシュ化
Module Module1 Sub Main() Dim origByte As Byte() = System.Text.Encoding.UTF8.GetBytes("Hello") Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider() Dim hashValue As Byte() = md5.ComputeHash(origByte) 'byte型配列を16進数の文字列に変換 Dim result As New System.Text.StringBuilder() Dim b As Byte For Each b In hashValue result.Append(b.ToString("x2")) Next Console.Write(result) Console.ReadLine() End Sub End Module
出力
8b1a9953c4611296a827abf8c47804d7
SHA256でハッシュ化
Module Module1 Sub Main() Dim origByte As Byte() = System.Text.Encoding.UTF8.GetBytes("Hello") Dim sha256 As System.Security.Cryptography.SHA256 = New System.Security.Cryptography.SHA256CryptoServiceProvider() Dim hashValue As Byte() = sha256.ComputeHash(origByte) 'byte型配列を16進数の文字列に変換 Dim result As New System.Text.StringBuilder() Dim b As Byte For Each b In hashValue result.Append(b.ToString("x2")) Next Console.Write(result) Console.ReadLine() End Sub End Module
実行結果
185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
参考文献
入力を受け取る input() - Python
ProgateでPythonの基礎を進めてる
標準入力から値を取得する方法をメモしておく
input
関数を使うことで標準入力から値を受け取ることができる
>>> a = input('数値を入力してください-> ') 数値を入力してください-> 2 >>> a '2'
input
関数は入力値を文字列に変換するため、数値として使うためにはキャストが必要
>>> type(a) <class 'str'> >>> b = int(a) >>> b 2
参考文献
DataGridViewでヘッダーをクリックしたら昇順、降順が変えられるようにする - VB.NET
カラムに対して設定してく
' ヘッダーセルクリックでソートを変えられるようになる column.SortMode = DataGridViewColumnSortMode.Automatic
参考文献
DataGridViewで指定のセルの背景色を変更する - VB.NET
dgv(colIndex, rowIndex).Style.BackColor = Color.Red
参考文献
DataGridViewでヘッダーをクリックしたら昇順、降順が変えられるようにする - VB.NET
カラムを追加した場合には自分で設定する
カラムに対して設定してく
' ヘッダーセルクリックでソートを変えられるようになる column.SortMode = DataGridViewColumnSortMode.Automatic
参考文献
多次元配列のある次元の要素数を取得する - VB.NET
多次元配列のある次元目の要素数を取得するには単純にはできなかった
配列.GetLength(次元数)
とすることで取得できた
Dim testArr(3, 2) As Integer Dim len0 As Integer = testArr.GetLength(0) ' 0次元目の要素数を取得 -> 4 Dim len1 As Integer = testArr.GetLength(1) ' 0次元目の要素数を取得 -> 3