<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CryptDecode アーカイブ - 自動売買を作ろう！</title>
	<atom:link href="https://mql-programing.com/archives/tag/cryptdecode/feed/" rel="self" type="application/rss+xml" />
	<link>https://mql-programing.com/archives/tag/cryptdecode/</link>
	<description>MQLプログラミング学習サイト</description>
	<lastBuildDate>Tue, 31 Mar 2026 13:07:19 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mql-programing.com/main29/wp-content/uploads/2021/02/cropped-ブログアイコン-32x32.jpg</url>
	<title>CryptDecode アーカイブ - 自動売買を作ろう！</title>
	<link>https://mql-programing.com/archives/tag/cryptdecode/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【MQL4定数】暗号化定数（ENUM_CRYPT_METHOD）</title>
		<link>https://mql-programing.com/archives/2798/enum_crypt_method/</link>
		
		<dc:creator><![CDATA[朝日奈りさ]]></dc:creator>
		<pubDate>Sat, 07 May 2022 12:53:21 +0000</pubDate>
				<category><![CDATA[【辞書】MQLリファレンス]]></category>
		<category><![CDATA[定数]]></category>
		<category><![CDATA[MQL]]></category>
		<category><![CDATA[リファレンス]]></category>
		<category><![CDATA[ENUM_CRYPT_METHOD]]></category>
		<category><![CDATA[CryptDecode]]></category>
		<category><![CDATA[CryptEncode]]></category>
		<guid isPermaLink="false">https://mql-programing.com/?p=2798</guid>

					<description><![CDATA[<p>暗号化定数（ENUM_CRYPT_METHOD） 暗号化定数（ENUM_CRYPT_METHOD）は、テキストなどを暗号化し、セキュリティを高めるために使用されます。 プログラムでパスワードを使用するときに、パスワードを [&#8230;]</p>
<p>投稿 <a href="https://mql-programing.com/archives/2798/enum_crypt_method/">【MQL4定数】暗号化定数（ENUM_CRYPT_METHOD）</a> は <a href="https://mql-programing.com">自動売買を作ろう！</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading"><span id="toc1">暗号化定数（ENUM_CRYPT_METHOD）</span></h2>



<p>暗号化定数（ENUM_CRYPT_METHOD）は、テキストなどを暗号化し、セキュリティを高めるために使用されます。</p>



<p>プログラムでパスワードを使用するときに、パスワードを暗号化をすると良いでしょう。</p>



<p>暗号化することで、セキュリティが高くなり、より信頼できる自動売買を作成することができます。</p>



<div style="height:79px" aria-hidden="true" class="wp-block-spacer"></div>



<p>暗号化、復号化するには、以下の関数を使用してください。</p>



<p><strong><span class="marker-under-red">暗号化するには、CryptEncode関数を使います。</span></strong></p>



<p><strong><span class="marker-under-red">暗号化を復号するには、CryptDecode関数を使います。</span></strong></p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading"><span id="toc2">暗号化定数（ENUM_CRYPT_METHOD）</span></h3>



<figure class="wp-block-table alignfull is-style-stripes"><table><tbody><tr><td><strong>定数</strong></td><td><strong>説明（暗号化の計算方法）</strong></td></tr><tr><td>CRYPT_BASE64</td><td>BASE64変換</td></tr><tr><td>CRYPT_AES128</td><td>128ビット(16バイト)キ―AES暗号化</td></tr><tr><td>CRYPT_AES256</td><td>256ビット(32バイト)キ―AES暗号化</td></tr><tr><td>CRYPT_DES</td><td>56ビット(7バイト)キ―DES暗号化</td></tr><tr><td>CRYPT_HASH_SHA1</td><td>SHA-1ハッシュ計算</td></tr><tr><td>CRYPT_HASH_SHA256</td><td>SHA-256ハッシュ計算</td></tr><tr><td>CRYPT_HASH_MD5</td><td>MD5ハッシュ計算</td></tr><tr><td>CRYPT_ARCH_ZIP</td><td>ZIPアーカイブ</td></tr></tbody></table></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><span id="toc3">暗号化定数の使い方</span></h2>



<p>主に、<strong>CryptEncode関数、CryptDecode関数</strong>で使用されます。</p>



<p>それぞれの関数の引数として使用されます。</p>



<p>例えば、以下のように使用します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-cpp" data-lang="C++"><code>void OnStart()
 {
  //暗号化するテキスト
  string text="Hello World";

  //暗号化するための鍵
  string keystr="ABCDEFG";

  //暗号化に使用する配列
  uchar src[],dst[],key[];

  //鍵をchar型の配列に変換
  StringToCharArray(keystr,key);

  //テキストをchar型の配列に変換
  StringToCharArray(text,src);

  //暗号化前のテキストを表示
  PrintFormat("Initial data: size=%d, string='%s'",ArraySize(src),CharArrayToString(src));

  //src[] を key[] を使って、56ビット(7バイト)キ―DESで暗号化
  //暗号化した結果を dst[] に格納
  int res=CryptEncode(CRYPT_DES,src,key,dst);

  //エラーをチェック
  if(res>0)
    {
    //dst[] を key[] を使って、56ビット(7バイト)キ―DESで復号化
    //復号化した結果を src[] に格納
    res=CryptDecode(CRYPT_DES,dst,key,src);

    //エラーをチェック 
    if(res>0)
       {
        //復号化されたテキストを表示
        PrintFormat("Decoded data: size=%d, string='%s'",ArraySize(src),CharArrayToString(src));
       }
    }
 }</code></pre></div>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><span id="toc4">プログラム例</span></h2>



<p>以下は、暗号化定数を使って文字列をAES256で暗号化し、復号化するサンプルプログラムです。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-cpp" data-lang="C++"><code>//+------------------------------------------------------------------+
//| 暗号化定数サンプルプログラム                                        |
//+------------------------------------------------------------------+
void OnStart()
 {
  //--- 暗号化するテキスト
  string text = "MQL4プログラミングで暗号化テスト";

  //--- 32バイトの鍵（AES256用）
  string keystr = "12345678901234567890123456789012";

  //--- 配列の宣言
  uchar src[], dst[], dec[], key[];

  //--- 文字列を配列に変換
  StringToCharArray(keystr, key);
  StringToCharArray(text, src);

  //--- 暗号化前のテキストを表示
  PrintFormat("【暗号化前】size=%d, text='%s'", ArraySize(src), CharArrayToString(src));

  //--- AES256で暗号化
  int encResult = CryptEncode(CRYPT_AES256, src, key, dst);

  if(encResult > 0)
    {
     PrintFormat("【暗号化成功】暗号化後のデータサイズ=%d", ArraySize(dst));

     //--- 暗号化データを16進数文字列で表示
     string hexStr = "";
     for(int i = 0; i < ArraySize(dst); i++)
       {
        hexStr += StringFormat("%02X", dst[i]);
       }
     PrintFormat("【暗号化データ(HEX)】%s", hexStr);

     //--- AES256で復号化
     int decResult = CryptDecode(CRYPT_AES256, dst, key, dec);

     if(decResult > 0)
       {
        PrintFormat("【復号化成功】size=%d, text='%s'", ArraySize(dec), CharArrayToString(dec));
       }
     else
       {
        PrintFormat("【復号化失敗】エラーコード=%d", GetLastError());
       }
    }
  else
    {
     PrintFormat("【暗号化失敗】エラーコード=%d", GetLastError());
    }

  //--- ハッシュ計算の例（SHA256）
  uchar hash[];
  uchar dummy[];
  int hashResult = CryptEncode(CRYPT_HASH_SHA256, src, dummy, hash);

  if(hashResult > 0)
    {
     string hashStr = "";
     for(int i = 0; i < ArraySize(hash); i++)
       {
        hashStr += StringFormat("%02X", hash[i]);
       }
     PrintFormat("【SHA-256ハッシュ】%s", hashStr);
    }
 }</code></pre></div>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><span id="toc5">【補足】暗号化定数の列挙型（ENUM_CRYPT_METHOD）</span></h2>



<p>暗号化定数は、ENUM_CRYPT_METHOD​という<a href="https://mql-programing.com/enum/">列挙型</a>に含まれています。</p>



<p>列挙型は、定数群をひとまとめにしたものです。</p>



<p>以下のように使います。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-cpp" data-lang="C++"><code>ENUM_CRYPT_METHOD cryptMethod = CRYPT_DES;</code></pre></div>



<p>上記のようにプログラムすると、cryptMethod変数に CRYPT_DESの値が代入されます。</p>



<p>　</p>



<div class="wp-block-cocoon-blocks-button-1 button-block"><a href="https://mql-programing.com/sample_program/" class="btn btn-l btn-circle" target="_self">サンプルプログラムはこちら</a></div>



<p>　</p>



<figure class="wp-block-embed is-type-wp-embed is-provider-自動売買を作ろう！ wp-block-embed-自動売買を作ろう！"><div class="wp-block-embed__wrapper">

<a href="https://mql-programing.com/enum/" title="【MQLプログラミング基礎】列挙型とは？配列との違いを理解して使いこなそう！" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://i0.wp.com/mql-programing.com/main29/wp-content/uploads/2021/09/enum.jpg?fit=1200%2C675&#038;ssl=1" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【MQLプログラミング基礎】列挙型とは？配列との違いを理解して使いこなそう！</div><div class="blogcard-snippet external-blogcard-snippet">目次 列挙型とは？列挙型と配列の違い列挙型と配列のデータの取り出し方法の違い列挙型と配列のデータの取り出し方法のまとめ列挙型の構造と使い方列挙型の構造列挙型の使い方列挙型はどこで使われているのか列挙型のプログラム例まとめ</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=https://mql-programing.com/archives/1399/enum/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">mql-programing.com</div></div></div></div></a>
</div></figure>



<figure class="wp-block-embed is-type-wp-embed is-provider-自動売買を作ろう！ wp-block-embed-自動売買を作ろう！"><div class="wp-block-embed__wrapper">

<a href="https://mql-programing.com/make_autotrade_by_myself/" title="【MQL4プログラミング】自動売買の作り方！FXで使えるテンプレートあり" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://i0.wp.com/mql-programing.com/main29/wp-content/uploads/2021/09/make_autotrade_by_myself.jpg?fit=1200%2C675&#038;ssl=1" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【MQL4プログラミング】自動売買の作り方！FXで使えるテンプレートあり</div><div class="blogcard-snippet external-blogcard-snippet">目次 はじめにFX自動売買とはFX自動売買を作るための準備FX自動売買の作り方口座凍結の対策をするプログラムテンプレートを作る決済ロジックをプログラミングするプログラムテンプレートを作るエントリーロジックをプログラミング</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://mql-programing.com/archives/1605/make_autotrade_by_myself/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">mql-programing.com</div></div></div></div></a>
</div></figure>



<figure class="wp-block-embed is-type-wp-embed is-provider-自動売買を作ろう！ wp-block-embed-自動売買を作ろう！"><div class="wp-block-embed__wrapper">

<a href="https://mql-programing.com/mql-reference/" title="MQL4リファレンス【全データ一覧】" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス-160x90.jpg" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス-160x90.jpg 160w, https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス-300x169.jpg 300w, https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス-1024x576.jpg 1024w, https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス-768x432.jpg 768w, https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス-120x68.jpg 120w, https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス-320x180.jpg 320w, https://mql-programing.com/main29/wp-content/uploads/2021/02/MQLリファレンス.jpg 1120w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">MQL4リファレンス【全データ一覧】</div><div class="blogcard-snippet internal-blogcard-snippet">/*! elementor - v3.6.5 - 27-04-2022 */.e-container.e-container--row .elementor-spacer-inner{width:var(--spacer-size)}.e-</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://mql-programing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">mql-programing.com</div></div></div></div></a>
</div></figure>



<p>　</p>
<p>投稿 <a href="https://mql-programing.com/archives/2798/enum_crypt_method/">【MQL4定数】暗号化定数（ENUM_CRYPT_METHOD）</a> は <a href="https://mql-programing.com">自動売買を作ろう！</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
