Use this API to convert sslpkcs12.
540369
public static base_response convert(nitro_service client, sslpkcs12 resource) throws Exception {
		sslpkcs12 convertresource = new sslpkcs12();
		convertresource.outfile = resource.outfile;
		convertresource.Import = resource.Import;
		convertresource.pkcs12file = resource.pkcs12file;
		convertresource.des = resource.des;
		convertresource.des3 = resource.des3;
		convertresource.export = resource.export;
		convertresource.certfile = resource.certfile;
		convertresource.keyfile = resource.keyfile;
		convertresource.password = resource.password;
		convertresource.pempassphrase = resource.pempassphrase;
		return convertresource.perform_operation(client,"convert");
	}
594704
def to_cert(raw_cert)
      logger.debug "CertMunger raw_cert:\n#{raw_cert}"
      new_cert = build_cert(raw_cert)
      logger.debug "CertMunger reformatted_cert:\n#{new_cert}"
      logger.debug 'Returning OpenSSL::X509::Certificate.new on new_cert'

      OpenSSL::X509::Certificate.new new_cert
    end
1355178
public static java.security.cert.X509Certificate convert(javax.security.cert.X509Certificate cert) {
        try {
            byte[] encoded = cert.getEncoded();
            ByteArrayInputStream bis = new ByteArrayInputStream(encoded);
            java.security.cert.CertificateFactory cf
                = java.security.cert.CertificateFactory.getInstance("X.509");
            return (java.security.cert.X509Certificate)cf.generateCertificate(bis);
        } catch (java.security.cert.CertificateEncodingException e) {
        } catch (javax.security.cert.CertificateEncodingException e) {
        } catch (java.security.cert.CertificateException e) {
        }
        return null;
    }
1331823
def gb2312_to_euc(gb2312hex):
    
    hi, lo = int(gb2312hex[:2], 16), int(gb2312hex[2:], 16)
    hi, lo = hexd(hi + 0x80), hexd(lo + 0x80)

    euc = "%s%s" % (hi, lo)
    assert isinstance(euc, bytes)
    return euc
1098590
def convert(jkf)
      jkf = jkf.is_a?(Hash) ? jkf : JSON.parse(jkf)
      convert_root(jkf)
    end
972588
def ConvertToWireFormat(self, value):
    """"""
    # Is it a protobuf-based value?
    if hasattr(value.__class__, "protobuf"):
      if value.__class__.protobuf:
        type_name = ("type.googleapis.com/%s" %
                     value.__class__.protobuf.__name__)
      else:
        type_name = value.__class__.__name__
      data = value.SerializeToString()
    # Is it a primitive value?
    elif hasattr(value.__class__, "data_store_type"):
      wrapper_cls = self.__class__.WRAPPER_BY_TYPE[
          value.__class__.data_store_type]
      wrapped_data = wrapper_cls()
      wrapped_data.value = value.SerializeToDataStore()

      type_name = ("type.googleapis.com/google.protobuf.%s" %
                   wrapper_cls.__name__)
      data = wrapped_data.SerializeToString()
    else:
      raise ValueError("Can't convert value %s to an protobuf.Any value." %
                       value)

    any_value = AnyValue(type_url=type_name, value=data)
    output = _SerializeEntries(_GetOrderedEntries(any_value.GetRawData()))

    return (self.encoded_tag, VarintEncode(len(output)), output)
114957
public static X509CertImpl toImpl(X509Certificate cert)
            throws CertificateException {
        if (cert instanceof X509CertImpl) {
            return (X509CertImpl)cert;
        } else {
            return X509Factory.intern(cert);
        }
    }
1132426
def rsa_public_key_pkcs8_to_pkcs1(pkcs8_key):
    """"""
    decoded_values = decoder.decode(pkcs8_key, asn1Spec=PublicKeyInfo())

    try:
        decoded_key = decoded_values[0]
    except IndexError:
        raise ValueError("Invalid public key encoding.")

    return decoded_key["publicKey"].asOctets()
29915
def Convert(self, metadata, interface, token=None):
    """"""
    ip4_addresses = []
    ip6_addresses = []
    for addr in interface.addresses:
      if addr.address_type == addr.Family.INET:
        ip4_addresses.append(addr.human_readable_address)
      elif addr.address_type == addr.Family.INET6:
        ip6_addresses.append(addr.human_readable_address)
      else:
        raise ValueError("Invalid address type: %s" % addr.address_type)

    result = ExportedNetworkInterface(
        metadata=metadata,
        ifname=interface.ifname,
        ip4_addresses=" ".join(ip4_addresses),
        ip6_addresses=" ".join(ip6_addresses))

    if interface.mac_address:
      result.mac_address = interface.mac_address.human_readable_address

    yield result
614197
private KeyStore convertPemFileToKeyStore(Path pemFile) {
		String pem;
		try {
			pem = FileUtils.readFileToString(pemFile.toFile(), StandardCharsets.US_ASCII);
		} catch (IOException e) {
			logger.warn("Failed to read .pem file:", e);
			JOptionPane.showMessageDialog(
					this,
					Constant.messages.getString("dynssl.importpem.failedreadfile", e.getLocalizedMessage()),
					Constant.messages.getString("dynssl.importpem.failed.title"),
					JOptionPane.ERROR_MESSAGE);
			return null;
		}

		byte[] cert;
		try {
			cert = SslCertificateUtils.extractCertificate(pem);
			if (cert.length == 0) {
				JOptionPane.showMessageDialog(
						this,
						Constant.messages.getString(
								"dynssl.importpem.nocertsection",
								SslCertificateUtils.BEGIN_CERTIFICATE_TOKEN,
								SslCertificateUtils.END_CERTIFICATE_TOKEN),
						Constant.messages.getString("dynssl.importpem.failed.title"),
						JOptionPane.ERROR_MESSAGE);
				return null;
			}
		} catch (IllegalArgumentException e) {
			logger.warn("Failed to base64 decode the certificate from .pem file:", e);
			JOptionPane.showMessageDialog(
					this,
					Constant.messages.getString("dynssl.importpem.certnobase64"),
					Constant.messages.getString("dynssl.importpem.failed.title"),
					JOptionPane.ERROR_MESSAGE);
			return null;
		}

		byte[] key;
		try {
			key = SslCertificateUtils.extractPrivateKey(pem);
			if (key.length == 0) {
				JOptionPane.showMessageDialog(
						this,
						Constant.messages.getString(
								"dynssl.importpem.noprivkeysection",
								SslCertificateUtils.BEGIN_PRIVATE_KEY_TOKEN,
								SslCertificateUtils.END_PRIVATE_KEY_TOKEN),
						Constant.messages.getString("dynssl.importpem.failed.title"),
						JOptionPane.ERROR_MESSAGE);
				return null;
			}
		} catch (IllegalArgumentException e) {
			logger.warn("Failed to base64 decode the private key from .pem file:", e);
			JOptionPane.showMessageDialog(
					this,
					Constant.messages.getString("dynssl.importpem.privkeynobase64"),
					Constant.messages.getString("dynssl.importpem.failed.title"),
					JOptionPane.ERROR_MESSAGE);
			return null;
		}

		try {
			return SslCertificateUtils.pem2KeyStore(cert, key);
		} catch (Exception e) {
			logger.error("Error creating KeyStore for Root CA cert from .pem file:", e);
			JOptionPane.showMessageDialog(
					this,
					Constant.messages.getString("dynssl.importpem.failedkeystore", e.getLocalizedMessage()),
					Constant.messages.getString("dynssl.importpem.failed.title"),
					JOptionPane.ERROR_MESSAGE);
			return null;
		}
	}
653399
def deserialize(cls, serialized):
        ''' 
        '''
        return PublicKey(
            nacl.public.PublicKey(serialized,
                                  encoder=nacl.encoding.Base64Encoder))
648243
def convert(self):
        """"""
        c = self.config
        c &= (~MCP342x._continuous_mode_mask & 0x7f)  # Force one-shot
        c |= MCP342x._not_ready_mask                  # Convert
        logger.debug('Convert ' + hex(self.address) + ' config: ' + bin(c))
        self.bus.write_byte(self.address, c)
1097375
def euc_to_python(hexstr):
    
    hi = hexstr[0:2]
    lo = hexstr[2:4]
    gb_enc = b'\\x' + hi + b'\\x' + lo
    return gb_enc.decode("gb2312")
1203895
def rsa_private_key_pkcs8_to_pkcs1(pkcs8_key):
    """"""
    decoded_values = decoder.decode(pkcs8_key, asn1Spec=PKCS8PrivateKey())

    try:
        decoded_key = decoded_values[0]
    except IndexError:
        raise ValueError("Invalid private key encoding")

    return decoded_key["privateKey"]
654279
private static X500Principal getX500Principal(X509Certificate cert,
            boolean getIssuer) throws Exception {
        byte[] encoded = cert.getEncoded();
        DerInputStream derIn = new DerInputStream(encoded);
        DerValue tbsCert = derIn.getSequence(3)[0];
        DerInputStream tbsIn = tbsCert.data;
        DerValue tmp;
        tmp = tbsIn.getDerValue();
        // skip version number if present
        if (tmp.isContextSpecific((byte)0)) {
          tmp = tbsIn.getDerValue();
        }
        // tmp always contains serial number now
        tmp = tbsIn.getDerValue();              // skip signature
        tmp = tbsIn.getDerValue();              // issuer
        if (getIssuer == false) {
            tmp = tbsIn.getDerValue();          // skip validity
            tmp = tbsIn.getDerValue();          // subject
        }
        byte[] principalBytes = tmp.toByteArray();
        return new X500Principal(principalBytes);
    }
410880
def to_native(self, obj):
        """"""
        ret = super(UserSerializer, self).to_native(obj)
        del ret['password']
        return ret
411646
def encode_uleb128(value)
      raise ArgumentError, "Signed integers are not supported" if value < 0
      return "\x00" if value == 0
      bytes = []
      while value != 0
        byte = value & 0b01111111 # 0x7f
        value >>= 7
        if value != 0
          byte |= 0b10000000 # 0x80
        end
        bytes << byte
      end
      return BTC::Data.data_from_bytes(bytes)
    end