-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: add dependency on ext-gmp * feat: add ability to xor strings * test: assert xor works * docs: add "app:xor-string"
- Loading branch information
1 parent
a50af18
commit 5d2896a
Showing
5 changed files
with
262 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Commands; | ||
|
||
use LaravelZero\Framework\Commands\Command; | ||
|
||
class XorString extends Command | ||
{ | ||
protected $signature = 'app:xor-string'; | ||
|
||
protected $description = 'XOR String with a variety of files from previous puzzles.'; | ||
|
||
public function handle(): int | ||
{ | ||
$string = $this->ask('Enter a string to XOR'); | ||
$key = $this->ask('Enter the key.'); | ||
|
||
$xor1 = gmp_init($string, 16); | ||
$xor2 = gmp_init($key, 16); | ||
|
||
$xor = gmp_xor($xor1, $xor2); | ||
$output = pack('H*', gmp_strval($xor, 16)); | ||
|
||
$this->output->write('XOR: '.$output.PHP_EOL); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.