Skip to content

Instantly share code, notes, and snippets.

/nsa.php Secret

Created October 29, 2016 16:00
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/7d19a35c54e7dac40fa1a470df4a209a to your computer and use it in GitHub Desktop.
break the nsa encryption
<?php
/**
* Encrypts a given plaintext using the supplied key.
*
* @param key a numeric key with a value greater than 255
* @param plainText a string containing the plaintext you want to encrypt
*
* @return number a unique number for this given key and plaintext
*/
function nsaEncrypt($key, $plainText)
{
$result = 0;
for ($character = 0; $character < strlen($plainText); $character++)
{
$result = bcadd($result, ord($plainText[$character]));
$result = bcmul($result, $key);
}
return $result;
}
/*
Here’s the ciphertext you need to deal with. It represents the encrypted version of a md5 hash. Decrypt it and then crack the hash to get the solution.
434384569820012709749978085023147407174684824178941182826833799495931410023794845922767533429746537016995520506439457550763575993604402054742042654701475990703513534158579743446096171193503041071008550601683001839024513922875537448251544812606790879783442587227277601837740236112564627038091170167413493638174350319534049389495771259593223970367601200671312435588244337256711215093040169407379877379400242759675821842258110296156050808143302683071999772732555638568114446076107646435540182476596386155629693774180289540430199704239923354089531930534807431109632462125230336414045829798557815327441670222304200
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment