Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $niz='HELLO';
- $key='DAVID';
- $key = str_split($key);
- $niz = str_split($niz);
- foreach($niz as $index => $element)
- {
- $bin = decbin(ord($element));
- $binar[] = $bin;
- }
- $niz = implode('',$binar);
- foreach($key as $index => $element)
- {
- $bin = decbin(ord($element));
- $kjuc[] = $bin;
- }
- $key = implode('',$kjuc);
- $in = str_split($niz);
- $out = str_split($key);
- foreach($in as $index => $element)
- {
- while ($index >= count($out))
- {
- $index = $index -count($out);
- }
- //index
- if($element == $out[$index])
- {
- $output[] = '0';
- }
- else
- {
- $output[] = '1';
- }
- }
- $izpis= (array_chunk($output, 7));
- foreach($izpis as $index => $element)
- {
- $konec[] = implode('',$element);
- }
- foreach($konec as $index => $element)
- {
- echo $element.' ';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement