bastien.monsarrat 6 жил өмнө
parent
commit
7c5cede7f3

+ 12 - 0
Adv2015.sln

@@ -15,6 +15,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D03.1", "D03.1\D03.1.csproj
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D03.2", "D03.2\D03.2.csproj", "{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D04.1", "D04.1\D04.1.csproj", "{D2A43230-DD77-407B-9503-05203D5CD3F6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D04.2", "D04.2\D04.2.csproj", "{3CD7AE1C-5114-4D29-AF54-1449110CB481}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -45,6 +49,14 @@ Global
 		{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{FBD5B3A5-4090-46DF-A513-FF463E8AB8DC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D2A43230-DD77-407B-9503-05203D5CD3F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D2A43230-DD77-407B-9503-05203D5CD3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D2A43230-DD77-407B-9503-05203D5CD3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D2A43230-DD77-407B-9503-05203D5CD3F6}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3CD7AE1C-5114-4D29-AF54-1449110CB481}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3CD7AE1C-5114-4D29-AF54-1449110CB481}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3CD7AE1C-5114-4D29-AF54-1449110CB481}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3CD7AE1C-5114-4D29-AF54-1449110CB481}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 9 - 0
D04.1/D04.1.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RootNamespace>D04._1</RootNamespace>
+  </PropertyGroup>
+
+</Project>

+ 35 - 0
D04.1/Program.cs

@@ -0,0 +1,35 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace D04._1
+{
+    class Program
+    {
+        static byte[] ToB(string str) => Encoding.ASCII.GetBytes(str);
+        static string ToS(byte[] b) => BitConverter.ToString(b).Replace("-", "");
+
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+
+            string hash = args[0];
+
+            int nbr = 0;
+            using (var md5 = MD5.Create())
+            {
+                do
+                {
+                    var h = md5.ComputeHash(ToB($"{hash}{nbr}"));
+                    if (ToS(h).StartsWith("00000")) break;
+
+                    nbr++;
+                } while (true);
+            }
+
+            Console.WriteLine($"Answer is : {nbr}");
+        }
+    }
+}

+ 8 - 0
D04.1/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D04.1": {
+      "commandName": "Project",
+      "commandLineArgs": "bgvyzdsv"
+    }
+  }
+}

+ 9 - 0
D04.2/D04.2.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RootNamespace>D04._2</RootNamespace>
+  </PropertyGroup>
+
+</Project>

+ 35 - 0
D04.2/Program.cs

@@ -0,0 +1,35 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace D04._2
+{
+    class Program
+    {
+        static byte[] ToB(string str) => Encoding.ASCII.GetBytes(str);
+        static string ToS(byte[] b) => BitConverter.ToString(b).Replace("-", "");
+
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+
+            string hash = args[0];
+
+            int nbr = 0;
+            using (var md5 = MD5.Create())
+            {
+                do
+                {
+                    var h = md5.ComputeHash(ToB($"{hash}{nbr}"));
+                    if (ToS(h).StartsWith("000000")) break;
+
+                    nbr++;
+                } while (true);
+            }
+
+            Console.WriteLine($"Answer is : {nbr}");
+        }
+    }
+}

+ 8 - 0
D04.2/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D04.2": {
+      "commandName": "Project",
+      "commandLineArgs": "bgvyzdsv"
+    }
+  }
+}