<commit_before><?php

namespace XeroPHP\Remote\OAuth\SignatureMethod;

use XeroPHP\Remote\OAuth\Exception;

class RSASHA1 implements SignatureMethodInterface {


    public static function generateSignature(array $config, $sbs, $secret) {
        // Fetch the private key
        if(false === $private_key_id = openssl_pkey_get_private($config['rsa_private_key']))
            throw new Exception('Cannot access private key for signing');

        // Sign using the key
        if(false === openssl_sign($sbs, $signature, $private_key_id)) {
            throw new Exception('Cannot sign signature base string.');
        }

        // Release the key resource
        openssl_free_key($private_key_id);

        return base64_encode($signature);
    }


}<commit_msg>Make inaccessable private key exception more informative<commit_after><?php

namespace XeroPHP\Remote\OAuth\SignatureMethod;

use XeroPHP\Remote\OAuth\Exception;

class RSASHA1 implements SignatureMethodInterface {


    public static function generateSignature(array $config, $sbs, $secret) {
        // Fetch the private key
        if(false === $private_key_id = openssl_pkey_get_private($config['rsa_private_key'])){
            throw new Exception("Cannot access private key for signing: openssl_pkey_get_private('${config['rsa_private_key']}') returned false");
        }

        // Sign using the key
        if(false === openssl_sign($sbs, $signature, $private_key_id)) {
            throw new Exception('Cannot sign signature base string.');
        }

        // Release the key resource
        openssl_free_key($private_key_id);

        return base64_encode($signature);
    }


}
{'fraction_non_alphanumeric': 0.10114388922335943, 'fraction_numerical': 0.003612281757977122, 'mean_word_length': 3.3168831168831168, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3309661', 'n_tokens_mistral': 473, 'n_tokens_neox': 454, 'n_words': 115}