結果

問題 No.3005 天使のハッシュ関数
ユーザー ecotteaecottea
提出日時 2022-10-04 01:14:25
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 1,365 bytes
コンパイル時間 7,865 ms
コンパイル使用メモリ 144,252 KB
実行使用メモリ 166,900 KB
最終ジャッジ日時 2023-08-27 22:33:37
合計ジャッジ時間 9,519 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
30,744 KB
testcase_01 AC 54 ms
30,544 KB
testcase_02 AC 53 ms
30,440 KB
testcase_03 AC 54 ms
30,616 KB
testcase_04 AC 58 ms
30,696 KB
testcase_05 AC 57 ms
32,432 KB
testcase_06 AC 56 ms
30,492 KB
testcase_07 AC 56 ms
32,280 KB
testcase_08 AC 56 ms
30,664 KB
testcase_09 AC 55 ms
30,680 KB
testcase_10 AC 54 ms
30,668 KB
testcase_11 AC 55 ms
30,304 KB
testcase_12 AC 56 ms
32,424 KB
testcase_13 AC 57 ms
166,900 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 157 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
/home/judge/data/code/Main.cs(17,22): warning SYSLIB0021: 'MD5CryptoServiceProvider' は旧形式です ('Derived cryptographic types are obsolete. Use the Create method on the base type instead.') [/home/judge/data/code/main.csproj]
/home/judge/data/code/Main.cs(33,23): warning SYSLIB0021: 'MD5CryptoServiceProvider' は旧形式です ('Derived cryptographic types are obsolete. Use the Create method on the base type instead.') [/home/judge/data/code/main.csproj]
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

// https://atmarkit.itmedia.co.jp/fdotnet/dotnettips/964computehash/computehash.html

using System;
using System.Security.Cryptography;
using System.Text;

class Program
{
  static void Main()
  {
    string originalText = Console.ReadLine();

    // テキストをUTF-8エンコードでバイト配列化
    byte[] byteValue = Encoding.UTF8.GetBytes(originalText);

    // MD5のハッシュ値を取得する
    MD5 crypto = new MD5CryptoServiceProvider();
    byte[] hashValue = crypto.ComputeHash(byteValue);

    // バイト配列をUTF8エンコードで文字列化
    StringBuilder hashedText = new StringBuilder();
    for (int i = 0; i < hashValue.Length; i++)
    {
      hashedText.AppendFormat("{0:x2}", hashValue[i]);
    }
    
    string originalText2 = hashedText.ToString();
    
    // テキストをUTF-8エンコードでバイト配列化
    byte[] byteValue2 = Encoding.UTF8.GetBytes(originalText2);

    // MD5のハッシュ値を取得する
    MD5 crypto2 = new MD5CryptoServiceProvider();
    byte[] hashValue2 = crypto.ComputeHash(byteValue2);

    // バイト配列をUTF8エンコードで文字列化
    StringBuilder hashedText2 = new StringBuilder();
    for (int i = 0; i < hashValue2.Length; i++)
    {
      hashedText2.AppendFormat("{0:x2}", hashValue2[i]);
    }
    Console.WriteLine(hashedText2.ToString());
  }
}
0