Get OpenSSL action from buffer

@private
@param {buffer} key Private key, certificate or CSR
@returns {string} OpenSSL action
8727
function getAction(key) {
    const keyString = key.toString();

    if (keyString.match(/CERTIFICATE\sREQUEST-{5}$/m)) {
        return 'req';
    }
    else if (keyString.match(/(PUBLIC|PRIVATE)\sKEY-{5}$/m)) {
        return 'rsa';
    }

    return 'x509';
}
401571
public static String RSAKeyToString (PublicKey key)
    {
        try {
            KeyFactory kf = KeyFactory.getInstance("RSA");
            RSAPublicKeySpec spec = kf.getKeySpec(key, RSAPublicKeySpec.class);
            StringBuilder buf = new StringBuilder();
            buf.append(spec.getModulus().toString(16))
                .append(SPLIT)
                .append(spec.getPublicExponent().toString(16));
            return buf.toString();
        } catch (GeneralSecurityException gse) {
            log.warning("Failed to convert key to string", gse);
        }
        return null;
    }
487686
function spop(key, req) {
  var val = this.getKey(key, req);
  if(val === undefined) return null;
  var element = val.spop();
  if(val.scard() === 0) {
    this.delKey(key, req);
  }
  return element;
}
77850
function getKey() {
      let paramString =
        width + 'x' + height + '-'
        + path
        + (is2x ? '-@2x' : '')
        + (bg ? `_${bg}` : '')
        + (crop ? '_crop' : '')
        + (mode ? `_${mode}` : '')
        + (trim ? '_trim' : '');

      return paramString + '-' + crypto.createHash('sha1').update(paramString).digest('hex');
    }
1133767
public static String RSAKeyToString (PrivateKey key)
    {
        try {
            KeyFactory kf = KeyFactory.getInstance("RSA");
            RSAPrivateKeySpec spec = kf.getKeySpec(key, RSAPrivateKeySpec.class);
            StringBuilder buf = new StringBuilder();
            buf.append(spec.getModulus().toString(16))
                .append(SPLIT)
                .append(spec.getPrivateExponent().toString(16));
            return buf.toString();
        } catch (GeneralSecurityException gse) {
            log.warning("Failed to convert key to string", gse);
        }
        return null;
    }
1017028
def key_file=(*args)
      path, passphrase = args.flatten
      ssl_context.key = OpenSSL::PKey::RSA.new(File.open(path), passphrase)
    end
65716
function otpauth(key, name) {
  var code = 'otpauth://totp/' + encodeURIComponent(name);
  code += '?secret=' + encodeURIComponent(key);
  code += '&issuer=' + encodeURIComponent('One Sony');
  return code;
}
696997
function _get(key){
	var ret = null;

	// Pull from cache or re-read from fs.
	//console.log('key: ' + key)
	//console.log('use_zcache_p: ' + use_zcache_p)
	if( use_zcache_p ){
	    ret = zcache[key];
	}else{
	    ret = afs.read_file(path_cache[key]);
	}

	return ret;
    }
894165
function getKeys (secret) {
	var hash = crypto.createHash('sha256').update(secret, 'utf8').digest();
	var keypair = naclInstance.crypto_sign_keypair_from_seed(hash);

	return {
		publicKey : Buffer.from(keypair.signPk).toString('hex'),
		privateKey : Buffer.from(keypair.signSk).toString('hex')
	};
}
854527
public void getActivation(String key) {
        ClientResource resource = new ClientResource(Route.ACTIVATE.url());
        Reference ref = resource.getReference();

        Map<String, Object> param = new HashMap<>();
        param.put("activation_key", key);

        Route.addParameters(ref, param);

        resource.get();
    }
939184
function(key) {
				var self = this;
				return this.done(function(s) {
					if (!key)
						return self._state;
					var out = self._state[key];
					return (typeof out === 'undefined') ? deep.Undefined : out;
				});
			}
1271354
public static sslcertkey get(nitro_service service, String certkey) throws Exception{
		sslcertkey obj = new sslcertkey();
		obj.set_certkey(certkey);
		sslcertkey response = (sslcertkey) obj.get_resource(service);
		return response;
	}
129774
private synchronized PublicKey fetchPublicKey(JsonNode messageJson) {
        URI certUrl = URI.create(messageJson.get(SIGNING_CERT_URL).asText());
        PublicKey publicKey = certificateCache.get(certUrl.toString());
        if (publicKey == null) {
            publicKey = createPublicKey(downloadCertWithRetries(certUrl));
            certificateCache.add(certUrl.toString(), publicKey);
        }
        return publicKey;
    }
278320
function getKey(key) {
  if(this.conf.transform) {
    if(typeof(this.conf.transform.key) == 'function') {
      return this.conf.transform.key.call(this, key);
    }
  }
  key = delimited(key, this.conf.delimiter);
  key = key.replace(/- /, this.conf.delimiter);
  key = key.replace(/[^a-zA-Z0-9_]/, '');
  if(this.conf.prefix) {
    return this.conf.prefix + this.conf.delimiter + key.toLowerCase()
  }
  return key.toLowerCase();
}
7456
def key=(*args)
      cert, passphrase = args.flatten
      ssl_context.key = OpenSSL::PKey::RSA.new(cert, passphrase)
    end
152441
function pemToRsaSSHKey(pem, comment) {
  assert.equal('string', typeof pem, 'typeof pem');

  // chop off the BEGIN PUBLIC KEY and END PUBLIC KEY portion
  var cleaned = pem.split('\n').slice(1, -2).join('');

  var buf = new Buffer(cleaned, 'base64');

  var der = new asn1.BerReader(buf);

  der.readSequence();
  der.readSequence();

  var oid = der.readOID();
  assert.equal(oid, '1.2.840.113549.1.1.1', 'pem not in RSA format');

  // Null -- XXX this probably isn't good practice
  der.readByte();
  der.readByte();

  // bit string sequence
  der.readSequence(0x03);
  der.readByte();
  der.readSequence();

  // modulus
  assert.equal(der.peek(), asn1.Ber.Integer, 'modulus not an integer');
  der._offset = der.readLength(der.offset + 1);
  var modulus = der._buf.slice(der.offset, der.offset + der.length);
  der._offset += der.length;

  // exponent
  assert.equal(der.peek(), asn1.Ber.Integer, 'exponent not an integer');
  der._offset = der.readLength(der.offset + 1);
  var exponent = der._buf.slice(der.offset, der.offset + der.length);
  der._offset += der.length;

  // now, make the key
  var type = new Buffer('ssh-rsa');
  var buffer = new Buffer(4 + type.length + 4 + modulus.length + 4 + exponent.length);
  var i = 0;
  buffer.writeUInt32BE(type.length, i);     i += 4;
  type.copy(buffer, i);                     i += type.length;
  buffer.writeUInt32BE(exponent.length, i); i += 4;
  exponent.copy(buffer, i);                 i += exponent.length;
  buffer.writeUInt32BE(modulus.length, i);  i += 4;
  modulus.copy(buffer, i);                  i += modulus.length;

  var s = type.toString() + ' ' + buffer.toString('base64') + ' ' + (comment || '');
  return s;
}
757028
public static String componentAccessToken(String key) {
		if (isKeyParam(key)) {
			return apiHandler.componentAccessToken(key);
		}
		return key;
	}