疑似コードとは? わかりやすく解説

擬似コード

(疑似コード から転送)

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2024/02/25 05:10 UTC 版)

擬似コード (ぎじコード、: pseudocode)とは、アルゴリズムなどを、架空の非常に高水準プログラミング言語擬似言語)で記述したものである。PascalFortranC言語などの既存のプログラミング言語の構文と、自然言語に近い表現を組み合わせて記述することが多い。

擬似コードの記述例を示す。下は、同様の記述を実際のプログラミング言語で表記したものである。

擬似コード:

if クレジットカード番号が有効
    番号と注文で取引をする
else
    エラーを表示する
end if

PHPによるコード:

<?php
 if (is_valid($cc_number)) {
     execute_transaction($cc_number, $order);
 }
 else {
     show_failure();
 }
?>

関連項目

外部リンク


疑似コード

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2022/06/29 03:46 UTC 版)

SHA-1」の記事における「疑似コード」の解説

SHA-1の疑似コードは以下の通りである。 Note 1: All variables are unsigned 32 bits and wrap modulo 232 when calculating, except ml the message length which is 64 bits, and hh the message digest which is 160 bits.Note 2: All constants in this pseudo code are in big endian. Within each word, the most significant byte is stored in the leftmost byte positionInitialize variables:h0 = 0x67452301h1 = 0xEFCDAB89h2 = 0x98BADCFEh3 = 0x10325476h4 = 0xC3D2E1F0ml = message length in bits (always a multiple of the number of bits in a character).Pre-processing:append the bit '1' to the message i.e. by adding 0x80 if characters are 8 bits.append 0 ≤ k < 512 bits '0', so that the resulting message length (in bits) is congruent to 448 (mod 512)append ml, as a 64-bit big-endian integer. So now the message length is a multiple of 512 bits.Process the message in successive 512-bit chunks:break message into 512-bit chunksfor each chunk break chunk into sixteen 32-bit big-endian words w[i], 0 ≤ i ≤ 15 Extend the sixteen 32-bit words into eighty 32-bit words: for i from 16 to 79 w[i] = (w[i-3] xor w[i-8] xor w[i-14] xor w[i-16]) leftrotate 1 Initialize hash value for this chunk: a = h0 b = h1 c = h2 d = h3 e = h4 Main loop: for i from 0 to 79 if 0 ≤ i ≤ 19 then f = (b and c) or ((not b) and d) k = 0x5A827999 else if 20 ≤ i ≤ 39 f = b xor c xor d k = 0x6ED9EBA1 else if 40 ≤ i ≤ 59 f = (b and c) or (b and d) or (c and d) k = 0x8F1BBCDC else if 60 ≤ i ≤ 79 f = b xor c xor d k = 0xCA62C1D6 temp = (a leftrotate 5) + f + e + k + w[i] e = d d = c c = b leftrotate 30 b = a a = temp Add this chunk's hash to result so far: h0 = h0 + a h1 = h1 + b h2 = h2 + c h3 = h3 + d h4 = h4 + eProduce the final hash value (big-endian) as a 160 bit number:hh = (h0 leftshift 128) or (h1 leftshift 96) or (h2 leftshift 64) or (h3 leftshift 32) or h4 hhメッセージダイジェストであり、十六進法 (base 16) あるいはBase64エンコード表現される定数は "nothing up my sleeve number" として選択される4つラウンド定数 k はそれぞれ 2、3、5、10の平方根230 倍の値である。状態値のうち h0 から h3 まではMD5と同じであり、h4 は類似したものである。 FIPS PUB 180-1によるもの代わりに下記の式をメインループでの f の計算用いることができる。 (0 ≤ i ≤ 19): f = d xor (b and (c xor d)) (alternative 1)(0 ≤ i ≤ 19): f = (b and c) xor ((not b) and d) (alternative 2)(0 ≤ i ≤ 19): f = (b and c) + ((not b) and d) (alternative 3)(0 ≤ i ≤ 19): f = vec_sel(d, c, b) (alternative 4) (40 ≤ i ≤ 59): f = (b and c) or (d and (b or c)) (alternative 1)(40 ≤ i ≤ 59): f = (b and c) or (d and (b xor c)) (alternative 2)(40 ≤ i ≤ 59): f = (b and c) + (d and (b xor c)) (alternative 3)(40 ≤ i ≤ 59): f = (b and c) xor (b and d) xor (c and d) (alternative 4) Max Locktyukhin は、32-79ラウンドにおける w[i] = (w[i-3] xor w[i-8] xor w[i-14] xor w[i-16]) leftrotate 1 を w[i] = (w[i-6] xor w[i-16] xor w[i-28] xor w[i-32]) leftrotate 2 で置換することが可能であることを示した

※この「疑似コード」の解説は、「SHA-1」の解説の一部です。
「疑似コード」を含む「SHA-1」の記事については、「SHA-1」の概要を参照ください。

ウィキペディア小見出し辞書の「疑似コード」の項目はプログラムで機械的に意味や本文を生成しているため、不適切な項目が含まれていることもあります。ご了承くださいませ。 お問い合わせ


英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「疑似コード」の関連用語

疑似コードのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



疑似コードのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアの擬似コード (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。
ウィキペディアウィキペディア
Text is available under GNU Free Documentation License (GFDL).
Weblio辞書に掲載されている「ウィキペディア小見出し辞書」の記事は、WikipediaのSHA-1 (改訂履歴)、SHA-2 (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。

©2025 GRAS Group, Inc.RSS