Didactic Feedback Cipher Long

Discussion of challenges you have already solved
Post Reply
johnpatcher
Posts: 6
Joined: Tue Oct 26, 2010 6:34 pm

Didactic Feedback Cipher Long

Post by johnpatcher »

Basically just a reminder for myself in case I want to revisit this challenge in the future:

Code: Select all

<?php

$str = "e5534adac53023aaad55518ac42671f8a1471d94d8676ce1b1".
       "1309c1c27a64b1ae1f4a91c73f2bfce74c5e8e826c27e1f74c".
       "4f8081296ff3ee4519968a6570e2aa0709c2c4687eece44a15".
       "89903e79ece75117cec73864eebe57119c9e367fefe9530dc1";

$arr = array_map("hexdec", array_reverse(str_split($str, 2)));

$str = "";

for($i = 0; $i < count($arr) - 4; $i++) {

    $str .= chr($arr[$i] ^ $arr[$i+4]);
    
}

echo strrev($str) . PHP_EOL;

Anyone came up with an easier solution?
Post Reply