src/Cos/cos-php-sdk-v4/qcloudcos/auth.php
private static function createSignature(
            $appId, $secretId, $secretKey, $expiration, $bucket, $fileId) {
        if (empty($secretId) || empty($secretKey)) {
            return self::AUTH_SECRET_ID_KEY_ERROR;
        }

        $now = time();
        $random = rand();
        $plainText = "a=$appId&k=$secretId&e=$expiration&t=$now&r=$random&f=$fileId&b=$bucket";
        $bin = hash_hmac('SHA1', $plainText, $secretKey, true);
        $bin = $bin.$plainText;

        $signature = base64_encode($bin);

        return $signature;
    }
private static function createSignature(
            $appId, $secretId, $secretKey, $expiration, $bucket, $fileId) {
        if (empty($secretId) || empty($secretKey)) {
            return self::AUTH_SECRET_ID_KEY_ERROR;
        }

        $now = time();
        $random = rand();
        $plainText = "a=$appId&k=$secretId&e=$expiration&t=$now&r=$random&f=$fileId&b=$bucket";
        $bin = hash_hmac('SHA1', $plainText, $secretKey, true);
        $bin = $bin.$plainText;

        $signature = base64_encode($bin);

        return $signature;
    }
private static function createSignature ( $ appId , $ secretId , $ secretKey , $ expiration , $ bucket , $ fileId ) { if ( empty ( $ secretId ) || empty ( $ secretKey ) ) { return self :: AUTH_SECRET_ID_KEY_ERROR ; } $ now = time ( ) ; $ random = rand ( ) ; $ plainText = "a=$appId&k=$secretId&e=$expiration&t=$now&r=$random&f=$fileId&b=$bucket" ; $ bin = hash_hmac ( 'SHA1' , $ plainText , $ secretKey , true ) ; $ bin = $ bin . $ plainText ; $ signature = base64_encode ( $ bin ) ; return $ signature ; }
A helper function for creating signature.
Return the signature on success.
Return error code if parameter is not valid.
A helper function for creating signature . Return the signature on success . Return error code if parameter is not valid .