処理の作成
This commit is contained in:
1 parent
409975baad
commit
5751bc7ea7
8 files changed
+267
-75
No files matched your search
Generated
-39
@@ -1,39 +0,0 @@
|
|||||||
namespace CryptoStringSHA
|
|
||||||
{
|
|
||||||
partial class Form1
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.components = new System.ComponentModel.Container();
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Text = "Form1";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
namespace CryptoStringSHA
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Generated
+169
@@ -0,0 +1,169 @@
|
|||||||
|
namespace CryptoStringSHA
|
||||||
|
{
|
||||||
|
partial class FrmMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
txtFrom = new TextBox();
|
||||||
|
txtTo = new TextBox();
|
||||||
|
btnRun = new Button();
|
||||||
|
rdoUp = new RadioButton();
|
||||||
|
rdoDown = new RadioButton();
|
||||||
|
rdo512 = new RadioButton();
|
||||||
|
rdo256 = new RadioButton();
|
||||||
|
grpRadio1 = new GroupBox();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
grpRadio1.SuspendLayout();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// txtFrom
|
||||||
|
//
|
||||||
|
txtFrom.Location = new Point(12, 12);
|
||||||
|
txtFrom.Name = "txtFrom";
|
||||||
|
txtFrom.Size = new Size(575, 23);
|
||||||
|
txtFrom.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// txtTo
|
||||||
|
//
|
||||||
|
txtTo.Location = new Point(12, 226);
|
||||||
|
txtTo.Name = "txtTo";
|
||||||
|
txtTo.Size = new Size(575, 23);
|
||||||
|
txtTo.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// btnRun
|
||||||
|
//
|
||||||
|
btnRun.Location = new Point(37, 99);
|
||||||
|
btnRun.Name = "btnRun";
|
||||||
|
btnRun.Size = new Size(75, 63);
|
||||||
|
btnRun.TabIndex = 2;
|
||||||
|
btnRun.Text = "↓";
|
||||||
|
btnRun.UseVisualStyleBackColor = true;
|
||||||
|
btnRun.Click += btnRun_Click;
|
||||||
|
//
|
||||||
|
// rdoUp
|
||||||
|
//
|
||||||
|
rdoUp.AutoSize = true;
|
||||||
|
rdoUp.Checked = true;
|
||||||
|
rdoUp.Location = new Point(22, 31);
|
||||||
|
rdoUp.Name = "rdoUp";
|
||||||
|
rdoUp.Size = new Size(73, 20);
|
||||||
|
rdoUp.TabIndex = 3;
|
||||||
|
rdoUp.TabStop = true;
|
||||||
|
rdoUp.Text = "大文字";
|
||||||
|
rdoUp.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// rdoDown
|
||||||
|
//
|
||||||
|
rdoDown.AutoSize = true;
|
||||||
|
rdoDown.Location = new Point(22, 62);
|
||||||
|
rdoDown.Name = "rdoDown";
|
||||||
|
rdoDown.Size = new Size(73, 20);
|
||||||
|
rdoDown.TabIndex = 4;
|
||||||
|
rdoDown.TabStop = true;
|
||||||
|
rdoDown.Text = "小文字";
|
||||||
|
rdoDown.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// rdo512
|
||||||
|
//
|
||||||
|
rdo512.AutoSize = true;
|
||||||
|
rdo512.Location = new Point(18, 62);
|
||||||
|
rdo512.Name = "rdo512";
|
||||||
|
rdo512.Size = new Size(73, 20);
|
||||||
|
rdo512.TabIndex = 6;
|
||||||
|
rdo512.TabStop = true;
|
||||||
|
rdo512.Text = "SHA512";
|
||||||
|
rdo512.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// rdo256
|
||||||
|
//
|
||||||
|
rdo256.AutoSize = true;
|
||||||
|
rdo256.Checked = true;
|
||||||
|
rdo256.Location = new Point(18, 31);
|
||||||
|
rdo256.Name = "rdo256";
|
||||||
|
rdo256.Size = new Size(73, 20);
|
||||||
|
rdo256.TabIndex = 5;
|
||||||
|
rdo256.TabStop = true;
|
||||||
|
rdo256.Text = "SHA256";
|
||||||
|
rdo256.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// grpRadio1
|
||||||
|
//
|
||||||
|
grpRadio1.Controls.Add(rdoUp);
|
||||||
|
grpRadio1.Controls.Add(rdoDown);
|
||||||
|
grpRadio1.Location = new Point(145, 77);
|
||||||
|
grpRadio1.Name = "grpRadio1";
|
||||||
|
grpRadio1.Size = new Size(120, 105);
|
||||||
|
grpRadio1.TabIndex = 7;
|
||||||
|
grpRadio1.TabStop = false;
|
||||||
|
grpRadio1.Text = "出力文字列";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(rdo256);
|
||||||
|
groupBox1.Controls.Add(rdo512);
|
||||||
|
groupBox1.Location = new Point(308, 77);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(110, 105);
|
||||||
|
groupBox1.TabIndex = 8;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "暗号化方法";
|
||||||
|
//
|
||||||
|
// FrmMain
|
||||||
|
//
|
||||||
|
ClientSize = new Size(599, 261);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(grpRadio1);
|
||||||
|
Controls.Add(btnRun);
|
||||||
|
Controls.Add(txtTo);
|
||||||
|
Controls.Add(txtFrom);
|
||||||
|
Font = new Font("MS ゴシック", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
MaximumSize = new Size(615, 300);
|
||||||
|
MinimumSize = new Size(615, 300);
|
||||||
|
Name = "FrmMain";
|
||||||
|
Text = "ハッシュ関数(SHA512)を使用してハッシュ値を計算";
|
||||||
|
grpRadio1.ResumeLayout(false);
|
||||||
|
grpRadio1.PerformLayout();
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox txtFrom;
|
||||||
|
private TextBox txtTo;
|
||||||
|
private Button btnRun;
|
||||||
|
private RadioButton rdoUp;
|
||||||
|
private RadioButton rdoDown;
|
||||||
|
private RadioButton rdo512;
|
||||||
|
private RadioButton rdo256;
|
||||||
|
private GroupBox grpRadio1;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CryptoStringSHA
|
||||||
|
{
|
||||||
|
public partial class FrmMain : Form
|
||||||
|
{
|
||||||
|
public FrmMain()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnRun_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
txtTo.Text = rdo256.Checked ? txtFrom.Text.CryptoSHA256(rdoUp.Checked) : txtFrom.Text.CryptoSHA512(rdoUp.Checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class StringExtensions
|
||||||
|
{
|
||||||
|
static readonly HashAlgorithm hashAlgorithm256 = SHA256.Create();
|
||||||
|
static readonly HashAlgorithm hashAlgorithm512 = SHA512.Create();
|
||||||
|
public static string CryptoSHA256(this string value, bool upperFlg)
|
||||||
|
{
|
||||||
|
//16 進文字列を大文字にしたい場合は $"{x:x2}" を $"{x:X2}" と変えれば OK です。
|
||||||
|
return string.Join("", hashAlgorithm256.ComputeHash(Encoding.ASCII.GetBytes(value)).Select(x => upperFlg ? $"{x:X2}" : $"{x:x2}"));
|
||||||
|
}
|
||||||
|
public static string CryptoSHA512(this string value, bool upperFlg)
|
||||||
|
{
|
||||||
|
//16 進文字列を大文字にしたい場合は $"{x:x2}" を $"{x:X2}" と変えれば OK です。
|
||||||
|
return string.Join("", hashAlgorithm512.ComputeHash(Encoding.ASCII.GetBytes(value)).Select(x => upperFlg ? $"{x:X2}" : $"{x:x2}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
@@ -26,36 +26,36 @@
|
|||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
||||||
@@ -11,7 +11,7 @@ namespace CryptoStringSHA
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
Application.Run(new FrmMain());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"runtimeTarget": {
|
||||||
|
"name": ".NETCoreApp,Version=v6.0",
|
||||||
|
"signature": ""
|
||||||
|
},
|
||||||
|
"compilationOptions": {},
|
||||||
|
"targets": {
|
||||||
|
".NETCoreApp,Version=v6.0": {
|
||||||
|
"CryptoStringSHA/1.0.0": {
|
||||||
|
"runtime": {
|
||||||
|
"CryptoStringSHA.dll": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libraries": {
|
||||||
|
"CryptoStringSHA/1.0.0": {
|
||||||
|
"type": "project",
|
||||||
|
"serviceable": false,
|
||||||
|
"sha512": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"runtimeOptions": {
|
||||||
|
"tfm": "net6.0",
|
||||||
|
"frameworks": [
|
||||||
|
{
|
||||||
|
"name": "Microsoft.NETCore.App",
|
||||||
|
"version": "6.0.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Microsoft.WindowsDesktop.App",
|
||||||
|
"version": "6.0.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user