Parody of Diffie-Hellman

Discussion in 'Coding, Scripting & Programming' started by HN-Matt, Dec 13, 2015.

  1. HN-Matt

    HN-Matt New Member Verified Provider

    611
    170
    Dec 19, 2013
    If you're new to PHP, here is a simple parody of Diffie-Hellman expressivity using for loops to get you started. Conversion to a bash script will not be very difficult and you'll be selling 'strong' encryption in no time! :)

    Code:
    <span style='font-family: monospace; font-size: 13px;'>
    <?php
    // parody of Diffie-Hellman
    for ($lines=1; $lines<=86; $lines++) {
       for ($dhm=1; $dhm<=150; $dhm++) {
          $dhparam = rand(1, 50);
          if ($dhparam == "1") {
             $dhparam = "+";
          } else {
             $dhparam = ".";
          }
          if ($lines != "86") {
             if ($dhm <= "150") {
                print $dhparam;
             }
          }
          if ($lines == "86") {
             if ($dhm < "145") {
                print $dhparam;
             } else {
                print "++*++*";
                break;
             }
          }
       }
       print "<br />";
    }
    ?>
    </span>
     
    Last edited by a moderator: Dec 13, 2015
  2. perennate

    perennate New Member Verified Provider

    387
    106
    May 15, 2013
  3. HN-Matt

    HN-Matt New Member Verified Provider

    611
    170
    Dec 19, 2013
    I guess it could be a lot of things, but I was referring to the output of 'openssl dhparam -out dhparams.pem wxyz' in particular.
     
    Last edited by a moderator: Dec 14, 2015