hello all,
i’m solving a ctf challenge and i have this function that decrypts the cipher
i want to build a function that encrypts plain text using
vmUeu7D9bzE5JmNE
as a key
example output:
//$EncString = encryptString("aaaaaaaaaaaaaaaaaaaaa", "vmUeu7D9bzE5JmNE");
output:SElIT1dBUkVZT1VCUk8hIdk8ZHn/lvhO9Vammhqvg8N6OlV2KOX3uRiQ7gsn8ZXuvE4UUPOK9Q4ZhufvCiyXhAIdJxY+22Rt5AgkVy0CDcI=```
decryption function :
function decryptString($ciphertext, $password)
{
$ciphertext = base64_decode($ciphertext);
if (!hash_equals(hash_hmac('sha256', substr($ciphertext, 48) . substr($ciphertext, 0, 16) , hash('sha256', $password, true) , true) , substr($ciphertext, 16, 32)))
return null;
return openssl_decrypt(substr($ciphertext, 48) , "AES-256-CBC", hash('sha256', $password, true) , OPENSSL_RAW_DATA, substr($ciphertext, 0, 16));
}
i want to reverse the decryption function , i tried but i couldn’t
Go to Source
Author: Mo Salah