I have this code in PHP:
private function encrypt_data($data)
{
$data .= $this->token;
$fingerprint = hash("sha512", $data);
$public_key_pem = openssl_pkey_get_public($this->public_rsa);
$private_key_pem = openssl_pkey_get_private($this->private_rsa);
openssl_sign($fingerprint, $signature, $private_key_pem, OPENSSL_ALGO_SHA512);
if (!openssl_verify($fingerprint, $signature, $public_key_pem, "sha512WithRSAEncryption")) {
return false;
}
$signature_base64_encoded = base64_encode($signature);
return [$fingerprint, $signature_base64_encoded];
}
I was wondering if i can replicate it in google app script but as im seeing google appscript doesnt have a built in function for RSA SHA_512 only HMAC SHA_512. for the fingerprint it has the Utilities.ComputeDigest so i need only the signing.