protected function getUsage($usage)
    {
        $map = array(
            Crypt_GPG_SubKey::USAGE_ENCRYPT        => 'encrypt',
            Crypt_GPG_SubKey::USAGE_SIGN           => 'sign',
            Crypt_GPG_SubKey::USAGE_CERTIFY        => 'cert',
            Crypt_GPG_SubKey::USAGE_AUTHENTICATION => 'auth',
        );

        // cert is always used for primary keys and does not need to be
        // specified
        $usage &= ~Crypt_GPG_SubKey::USAGE_CERTIFY;

        $usageArray = array();

        foreach ($map as $key => $value) {
            if (($usage & $key) === $key) {
                $usageArray[] = $value;
            }
        }

        return implode(',', $usageArray);
    }
protected function getUsage($usage)
    {
        $map = array(
            Crypt_GPG_SubKey::USAGE_ENCRYPT        => 'encrypt',
            Crypt_GPG_SubKey::USAGE_SIGN           => 'sign',
            Crypt_GPG_SubKey::USAGE_CERTIFY        => 'cert',
            Crypt_GPG_SubKey::USAGE_AUTHENTICATION => 'auth',
        );

        // cert is always used for primary keys and does not need to be
        // specified
        $usage &= ~Crypt_GPG_SubKey::USAGE_CERTIFY;

        $usageArray = array();

        foreach ($map as $key => $value) {
            if (($usage & $key) === $key) {
                $usageArray[] = $value;
            }
        }

        return implode(',', $usageArray);
    }
protected function getUsage ( $ usage ) { $ map = array ( Crypt_GPG_SubKey :: USAGE_ENCRYPT => 'encrypt' , Crypt_GPG_SubKey :: USAGE_SIGN => 'sign' , Crypt_GPG_SubKey :: USAGE_CERTIFY => 'cert' , Crypt_GPG_SubKey :: USAGE_AUTHENTICATION => 'auth' , ) ; // cert is always used for primary keys and does not need to be // specified $ usage &= ~ Crypt_GPG_SubKey :: USAGE_CERTIFY ; $ usageArray = array ( ) ; foreach ( $ map as $ key => $ value ) { if ( ( $ usage & $ key ) === $ key ) { $ usageArray [ ] = $ value ; } } return implode ( ',' , $ usageArray ) ; }
Builds a GnuPG key usage string suitable for key generation

See <b>doc/DETAILS</b> in the
{@link http://www.gnupg.org/download/ GPG distribution} for detailed
information on the key usage format.

@param integer $usage a bitwise combination of the key usages. This is
a combination of the Crypt_GPG_SubKey::USAGE_*
constants.

@return string the key usage string.
Builds a GnuPG key usage string suitable for key generation