mori– Author –
-
C#樹林
[C#] How to Decrypt Strings Encrypted with Symmetric Key Encryption (AES)
Overview This article explains how to return an encrypted string (in Base64 format) back to its original plaintext using a shared Key and Initialization Vector (IV). The decryption process is the reverse of encryption. You use CryptoStre... -
C#樹林
【C#】共通鍵暗号(AES)で暗号化された文字列を復号する方法
概要 暗号化された文字列(Base64形式)を、共通の鍵(Key)と初期化ベクトル(IV)を使用して元の平文に戻す実装です。 復号処理は暗号化の逆の手順となり、CryptoStream を「読み取りモード(Read)」で使用し、暗号化されたバイトデータをストリーム経... -
C#樹林
[C#] How to Encrypt Strings Using Symmetric Key Encryption (AES)
Overview To encrypt strings in .NET, you apply encryption to a data stream using the CryptoStream class. Since strings cannot be encrypted directly, the transformation follows this process: "String → Byte Array → Encryption Stream → Encr... -
C#樹林
【C#】共通鍵暗号(AES)で文字列を暗号化する方法
概要 .NETで文字列を暗号化するには、CryptoStream クラスを使用してデータの流れ(ストリーム)に対して暗号化処理を適用します。 文字列をそのまま暗号化することはできないため、「文字列 → バイト列 → 暗号化ストリーム → 暗号化されたバイト列」とい... -
C#樹林
[C#] How to Generate Encryption Keys and Initialization Vectors (IV) for Symmetric Encryption
Overview To perform secure communication using symmetric encryption like AES (Advanced Encryption Standard), both the encryption and decryption processes must share the same "Key" and "Initialization Vector (IV)." By using classes in the... -
C#樹林
【C#】共通鍵暗号方式の暗号化キーと初期化ベクトル(IV)を生成する方法
概要 AESなどの共通鍵暗号方式(Symmetric Algorithm)で安全な通信を行うには、暗号化と復号で同じ「キー(Key)」と「初期化ベクトル(IV: Initialization Vector)」を共有する必要があります。 .NETの System.Security.Cryptography 名前空間に含まれ... -
C#樹林
[C#] How to Send Emails with Attachments Using MailKit
Overview When sending files such as images or documents via email, you must build a MIME (Multipurpose Internet Mail Extensions) multipart structure. This is different from a simple text email. By using the BodyBuilder class from the Mai... -
C#樹林
【C#】MailKitで添付ファイル付きのメールを送信する方法
概要 メールに画像やドキュメントなどのファイルを添付する場合、単純なテキストメールとは異なり、MIME(Multipurpose Internet Mail Extensions)のマルチパート構造を構築する必要があります。 MailKitライブラリの BodyBuilder クラスを使用することで... -
C#樹林
[C#] How to Send Emails Using MailKit
Overview When implementing email functionality in .NET, the standard System.Net.Mail.SmtpClient is now considered obsolete. Microsoft recommends using the open-source library MailKit instead. By using MailKit, you can easily and securely... -
C#樹林
【C#】MailKitを使用してメールを送信する方法
概要 .NETでメール送信機能を実装する場合、標準ライブラリの System.Net.Mail.SmtpClient は現在「旧式(Obsolete)」扱いとなっており、マイクロソフトはオープンソースライブラリである MailKit の使用を推奨しています。 MailKitを使用することで、最... -
C#樹林
[C#]How to Output HttpClient Communication Logs and Check Request Content
Overview When using IHttpClientFactory, you can output communication details such as HTTP request starts, ends, headers, and status codes simply by changing the log settings. This is a very effective debugging method for tracking what he... -
C#樹林
【C#】HttpClientの通信ログを出力してリクエスト内容を確認する方法
概要 IHttpClientFactory を使用している場合、ログ設定を変更するだけで HTTP リクエストの開始、終了、ヘッダー情報、ステータスコードなどの通信詳細をログに出力できます。 APIとの通信トラブル時に「どんなヘッダーを送ったか」「どのURLにアクセスし... -
C#樹林
[C#]How to Correctly Create HttpClient Using IHttpClientFactory in C#
Overview This implementation pattern uses IHttpClientFactory to solve issues like "socket exhaustion" and "DNS changes not being reflected," which occur when new HttpClient() is reused incorrectly or disposed of too quickly. You inject t... -
C#樹林
【C#】IHttpClientFactoryを使ってHttpClientを正しく生成する方法
概要 従来の new HttpClient() の使い回しや使い捨てによって発生する「ソケット枯渇問題」や「DNS変更が反映されない問題」を解決するために、推奨されている IHttpClientFactory を使用する実装パターンです。 Dependency Injection (DI) コンテナを介し... -
C#樹林
[C#] How to POST JSON Data with HttpClient
Overview This article covers the fundamental implementation for sending JSON-formatted data to a Web API. The process involves serializing a C# object into a JSON string and using the StringContent class to send a POST request with the C... -
C#樹林
【C#】HttpClientでJSONデータをPOST送信する方法
概要 Web APIに対してJSON形式のデータを送信する基本的な実装です。 オブジェクトをJSON文字列にシリアライズし、StringContent クラスを使用して Content-Type: application/json ヘッダーと共にPOSTリクエストを送信します。 仕様(入出力) 入力: 送信... -
C#樹林
[C#] How to POST Form Data (x-www-form-urlencoded) with HttpClient
Overview This method allows you to send data in the application/x-www-form-urlencoded format, which is the same format used by standard HTML <form> tags. By using the FormUrlEncodedContent class, key-value pairs are automatically U... -
C#樹林
【C#】HttpClientでフォームデータ(x-www-form-urlencoded)をPOST送信する方法
概要 Webページの一般的な入力フォーム(<form>タグ)と同じ形式である application/x-www-form-urlencoded でデータを送信する方法です。 FormUrlEncodedContent クラスを使用することで、キーと値のペアを自動的にURLエンコードし、適切な Content... -
C#樹林
[C#] Detailed Control over HTTP Methods and Headers using SendAsync
Overview While HttpClient provides convenient shorthand methods like GetAsync and PostAsync, the SendAsync method is the preferred choice for granular control. By utilizing the HttpRequestMessage class, you can set individual headers per... -
C#樹林
【C#】HTTPメソッドとヘッダーを詳細に制御してAPIを呼び出す方法
概要 HttpClient には GetAsync や PostAsync といった便利な短縮メソッドが用意されていますが、より細かい制御を行いたい場合は SendAsync メソッドを使用します。 HttpRequestMessage クラスを組み合わせることで、リクエストごとに個別のヘッダーを設... -
C#樹林
[C#] How to Branch Logic Based on HttpClient HTTP Status Codes
Overview When sending web requests using HttpClient, a communication success doesn't always mean the server processed the request as intended. The server might return "Page Not Found (404)" or an "Internal Error (500)." By checking the H... -
C#樹林
【C#】HttpClientでHTTPステータスコードを判定して分岐処理する方法
概要 HttpClient を使用してWebリクエストを送信した際、通信自体は成功しても、サーバー側で「ページが見つからない(404)」や「内部エラー(500)」が発生している場合があります。 HttpResponseMessage.StatusCode プロパティを確認することで、サーバ... -
C#樹林
[C#] Setting the User-Agent in HttpClient Request Headers
Overview When performing web scraping or using specific Web APIs, it is often mandatory to set the User-Agent header to inform the server about the client making the request. In HttpClient, there are two main ways to specify this: by dir... -
C#樹林
【C#】HttpClientでリクエストヘッダーにUser-Agentを設定する方法
概要 Webスクレイピングや特定のWeb APIを利用する際、クライアント(呼び出し元)の情報をサーバーに伝えるために User-Agent ヘッダーの設定が必須となる場合があります。 HttpClient では、文字列を直接指定する方法と、専用のクラスを使用して構造的に... -
Linux樹林
[Linux] Creating New Directories with the mkdir Command
Overview mkdir (make directory) is the fundamental command used to create new directories (folders) in Linux. Beyond simply creating a single folder, it allows you to generate deep hierarchies in a single step and set access permissions ... -
Linux樹林
【Linux】mkdirコマンドで新しいディレクトリを作成する
概要 mkdir(make directory)は、新しいディレクトリ(Windowsでいうフォルダ)を作成するための基本コマンドです。 単に箱を作るだけでなく、深い階層のディレクトリを一発で作成したり、作成と同時にアクセス権限(パーミッション)を設定したりするこ... -
Linux樹林
[Linux] Cloning Disks, Creating Images, and Converting Data with the dd Command
Overview The dd command is a tool used for low-level copying and conversion of data between files and devices using specified block sizes. Unlike the standard cp command, dd can directly read and write to device files (e.g., /dev/sda). T... -
Linux樹林
【Linux】ddコマンドでディスクの複製・イメージ作成・データ変換を行う
概要 ddコマンドは、ファイルやデバイスに対して、指定されたブロック単位での低レベルコピーと変換を行うツールです。 通常のcpコマンドとは異なり、ハードディスクやUSBメモリなどのデバイスファイル(/dev/sdaなど)を直接読み書きできるため、ディスク... -
Linux樹林
[Linux] Deploying Files while Setting Permissions with the install Command
Overview The install command is used to copy files while simultaneously setting their access permissions (mode), owner, and group. While the name suggests it is only for software installation, it is effectively a high-functioning copy co... -
Linux樹林
【Linux】installコマンドで権限を設定しながらファイルを配置する
概要 installコマンドは、ファイルをコピーすると同時に、そのファイルの「アクセス権限(パーミッション)」「所有者」「所属グループ」を設定するためのコマンドです。 名前から「ソフトウェアのインストール専用」と思われがちですが、実際には「高機能...