Gets the Base64 encoded public key that forms part of this instance's identity keypair.
@return the Base64 encoded public key
@since 2.16
772132
@Nullable
    public String getIdentityPublicKey() {
        RSAPublicKey key = InstanceIdentityProvider.RSA.getPublicKey();
        return key == null ? null : new String(Base64.encodeBase64(key.getEncoded()), Charset.forName("UTF-8"));
    }
1027607
public static byte[] generateKey()
        throws GeneralSecurityException
    {
        KeyGenerator keyGenerator = KeyGenerator.getInstance(KEY_ALGORITHM);
        // java max 128
        keyGenerator.init(128);
        SecretKey secretKey = keyGenerator.generateKey();
        return secretKey.getEncoded();
    }
1153519
private static String getBase64Key() {
		if (base64Key == null) {
			base64Key = SharedPreferencesHelper.get().loadPreference(BASE64_KEY);
			if (base64Key == null) {
				base64Key = generateBase64Key();
				SharedPreferencesHelper.get().savePreference(BASE64_KEY, base64Key);
			}
		}
		return base64Key;
	}
284557
public static String getUUID() {
        UUID id = UUID.randomUUID();
        ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
        bb.putLong(id.getMostSignificantBits());
        bb.putLong(id.getLeastSignificantBits());
        return Base64.encodeBase64URLSafeString(bb.array());
    }
227904
protected static function getBase64EncryptionKey() {	    
	    $key = 'STANDARDKEYIFNOSERVER';
	    if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
	        $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
	    
	    return $key;
	}
433067
public byte[] getEncoded() throws SshException {
		ByteArrayWriter baw = new ByteArrayWriter();
		try {

			baw.writeString(getAlgorithm());
			baw.writeBigInteger(pubkey.getParams().getP());
			baw.writeBigInteger(pubkey.getParams().getQ());
			baw.writeBigInteger(pubkey.getParams().getG());
			baw.writeBigInteger(pubkey.getY());

			return baw.toByteArray();
		} catch (IOException ioe) {
			throw new SshException("Failed to encoded DSA key",
					SshException.INTERNAL_ERROR, ioe);
		} finally {
			try {
				baw.close();
			} catch (IOException e) {
			}
		}
	}
694621
public Key getKey()
    {
        final Key ret = new Key().setPersonId(getPersonId())
                        .setCompanyId(getCompanyId())
                        .setTypeId(getTypeId());
        return ret;
    }
682193
@Override
  public final PublicKey lazyGetPublicKeyAnotherAjetty() throws Exception {
    if (this.publicKeyAnotherAjetty == null && this.publicKeyDir != null
      && lazyGetOurPublicKey() != null) {
      File pkDir = new File(this.publicKeyDir);
      if (pkDir.exists()) {
        File[] lstFl = pkDir.listFiles();
        if (lstFl != null && lstFl.length == 1 && lstFl[0].isFile()) {
          FileInputStream fis = null;
          try {
            fis = new FileInputStream(lstFl[0]);
            ByteArrayOutputStream baus = new ByteArrayOutputStream();
            int b;
            while ((b = fis.read()) != -1) {
              baus.write(b);
            }
            byte[] encKey = baus.toByteArray();
            X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(encKey);
            KeyFactory keyFactory = KeyFactory
              .getInstance("RSA", this.cryptoProvider);
            PublicKey pkaj = keyFactory.generatePublic(pubKeySpec);
            if (!lazyGetOurPublicKey().equals(pkaj)) {
              this.publicKeyAnotherAjetty = pkaj;
            }
          } finally {
            if (fis != null) {
              try {
                fis.close();
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          }
        }
      }
    }
    return this.publicKeyAnotherAjetty;
  }
874624
public function getKey() {
		if(!$this->decrypted_key) {

			$decoded_ciphertextblob = base64_decode($this->key_description->getCiphertextBlob(), true);
			if(!$decoded_ciphertextblob) {
				throw new FetchException('CiphertextBlob should be a valid base64 encoded string');
			}

			$options = [
				'CiphertextBlob' => $decoded_ciphertextblob
			];

			$context = $this->key_description->getEncryptionContextAsArray();
			if(!empty($context)) {
				$options['EncryptionContext'] = $context;
			}

			try {
				$response = $this->client->decrypt($options);
			}
			catch(KmsException $e) {
				throw new FetchException('Key decryption failed', 0, $e);
			}

			$this->decrypted_key = $response['Plaintext'];
		}

		return $this->decrypted_key;
	}
438680
@JsonIgnore
    public String getSigningCertificateDecoded() {
        if (EncodingUtils.isBase64(signingCertificate)) {
            return EncodingUtils.decodeBase64ToString(signingCertificate);
        }
        return signingCertificate;
    }
894875
public static PublicKey createPublicKey(byte[] publicKey) {
    if (publicKey == null) {
      return null;
    }
    
    try {
      KeyFactory fac = KeyFactory.getInstance("RSA");
      EncodedKeySpec spec = new X509EncodedKeySpec(publicKey);
      return fac.generatePublic(spec);
    }
    catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException(e);
    }
    catch (InvalidKeySpecException e) {
      throw new IllegalStateException(e);
    }
  }
1121541
public byte[] keygen() throws IOException {
		byte inkey[] = new byte[0x600];
		new SecureRandom().nextBytes(inkey);
		ByteArrayOutputStream baos = new ByteArrayOutputStream(0x800);
		base64url.encode(new ByteArrayInputStream(inkey), baos);
		return baos.toByteArray();
   }
309867
private final boolean verify() throws Exception {
        String dataStr = this.getUserData().toString();
        byte[] data = Base64Coder.getBytes(dataStr);
        return verify(data, signature, publicKey);
    }
215315
public function generateKey()
    {
        if (extension_loaded('openssl')) {
            $key = openssl_random_pseudo_bytes(16);
        } else {
            // SHA1 is 128 bit (= 16 bytes)
            $key = sha1(spl_object_hash($this) . mt_rand(0, PHP_INT_MAX) . uniqid('', true), true);
        }

        return base64_encode($key);
    }
479615
public byte[] getEncoded() throws SshException {

		try {
			return cert.getEncoded();
		} catch (Throwable ex) {
			throw new SshException("Failed to encoded key data",
					SshException.INTERNAL_ERROR, ex);
		}
	}
579591
protected String getEncryptionKey() {
        if (extendedMetadata != null && extendedMetadata.getEncryptionKey() != null) {
            return extendedMetadata.getEncryptionKey();
        } else {
            return keyManager.getDefaultCredentialName();
        }
    }
1141696
public String[] keypairZ85()
    {
        String[] pair = new String[2];

        byte[] publicKey = new byte[Size.PUBLICKEY.bytes()];
        byte[] secretKey = new byte[Size.SECRETKEY.bytes()];

        int rc = curve25519xsalsa20poly1305.crypto_box_keypair(publicKey, secretKey);
        assert (rc == 0);

        pair[0] = Z85.encode(publicKey, Size.PUBLICKEY.bytes());
        pair[1] = Z85.encode(secretKey, Size.SECRETKEY.bytes());

        return pair;
    }