Advertisement
yacked2

[php] cezar-decrypt

Mar 24th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2. $key = 11;
  3. $vhod = 'YL LOKUPKUEDBTKJUEDBLU';
  4. $abeceda = array(1=>'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ');
  5.  
  6. $niz = strtoupper($vhod);
  7. $array = str_split($niz);
  8.  
  9. foreach($array as $index => $element)
  10. {
  11.    $value = array_search($element, $abeceda);//crke zamenjamo s številkami
  12.    $value = $value - $key;
  13.    
  14.    if($value <= 0)
  15.    {
  16.       $value = $value + count($abeceda);
  17.    }
  18.    
  19.    $hash = $abeceda[$value];
  20.    $output[] = $hash;
  21.  
  22. }
  23.  
  24. foreach($output as $index => $element)
  25. {
  26.    if($element == null)
  27.    {
  28.    $output[$index] = ' ';
  29.    }
  30. }
  31.  
  32. $izpis = implode('',$output);
  33. echo $izpis;
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement