diff --git a/CryptoStringSHA/Form1.Designer.cs b/CryptoStringSHA/Form1.Designer.cs deleted file mode 100644 index e934dc9..0000000 --- a/CryptoStringSHA/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace CryptoStringSHA -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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 - } -} \ No newline at end of file diff --git a/CryptoStringSHA/Form1.cs b/CryptoStringSHA/Form1.cs deleted file mode 100644 index c27bb59..0000000 --- a/CryptoStringSHA/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CryptoStringSHA -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/CryptoStringSHA/FrmMain.Designer.cs b/CryptoStringSHA/FrmMain.Designer.cs new file mode 100644 index 0000000..b15e281 --- /dev/null +++ b/CryptoStringSHA/FrmMain.Designer.cs @@ -0,0 +1,169 @@ +namespace CryptoStringSHA +{ + partial class FrmMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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("ï¼­ï¼³ ゴシック", 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; + } +} \ No newline at end of file diff --git a/CryptoStringSHA/FrmMain.cs b/CryptoStringSHA/FrmMain.cs new file mode 100644 index 0000000..8689f38 --- /dev/null +++ b/CryptoStringSHA/FrmMain.cs @@ -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 �i•¶Žš—ñ‚ð‘å•¶Žš‚É‚µ‚½‚¢�ê�‡‚Í $"{x:x2}" ‚ð $"{x:X2}" ‚ƕς¦‚ê‚Î OK ‚Å‚·�B + 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 �i•¶Žš—ñ‚ð‘å•¶Žš‚É‚µ‚½‚¢�ê�‡‚Í $"{x:x2}" ‚ð $"{x:X2}" ‚ƕς¦‚ê‚Î OK ‚Å‚·�B + return string.Join("", hashAlgorithm512.ComputeHash(Encoding.ASCII.GetBytes(value)).Select(x => upperFlg ? $"{x:X2}" : $"{x:x2}")); + } + } +} \ No newline at end of file diff --git a/CryptoStringSHA/Form1.resx b/CryptoStringSHA/FrmMain.resx similarity index 93% rename from CryptoStringSHA/Form1.resx rename to CryptoStringSHA/FrmMain.resx index 1af7de1..af32865 100644 --- a/CryptoStringSHA/Form1.resx +++ b/CryptoStringSHA/FrmMain.resx @@ -1,17 +1,17 @@  - diff --git a/CryptoStringSHA/Program.cs b/CryptoStringSHA/Program.cs index 2841d2c..be922b7 100644 --- a/CryptoStringSHA/Program.cs +++ b/CryptoStringSHA/Program.cs @@ -11,7 +11,7 @@ namespace CryptoStringSHA // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FrmMain()); } } } \ No newline at end of file diff --git a/CryptoStringSHA/bin/Debug/net6.0-windows/CryptoStringSHA.deps.json b/CryptoStringSHA/bin/Debug/net6.0-windows/CryptoStringSHA.deps.json new file mode 100644 index 0000000..c7ab3a3 --- /dev/null +++ b/CryptoStringSHA/bin/Debug/net6.0-windows/CryptoStringSHA.deps.json @@ -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": "" + } + } +} \ No newline at end of file diff --git a/CryptoStringSHA/bin/Debug/net6.0-windows/CryptoStringSHA.runtimeconfig.json b/CryptoStringSHA/bin/Debug/net6.0-windows/CryptoStringSHA.runtimeconfig.json new file mode 100644 index 0000000..f9988b2 --- /dev/null +++ b/CryptoStringSHA/bin/Debug/net6.0-windows/CryptoStringSHA.runtimeconfig.json @@ -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" + } + ] + } +} \ No newline at end of file