Stay organized with collections
Save and categorize content based on your preferences.
KeyPair
class KeyPair : Serializable
This class is a simple holder for a key pair (a public key and a private key). It does not enforce any security, and, when initialized, should be treated like a PrivateKey.
Summary
Public constructors |
Constructs a key pair from the given public key and private key.
|
Public methods |
PrivateKey! |
Returns a reference to the private key component of this key pair.
|
PublicKey! |
Returns a reference to the public key component of this key pair.
|
Public constructors
KeyPair
KeyPair(
publicKey: PublicKey!,
privateKey: PrivateKey!)
Constructs a key pair from the given public key and private key.
Note that this constructor only stores references to the public and private key components in the generated key pair. This is safe, because Key
objects are immutable.
Public methods
getPrivate
fun getPrivate(): PrivateKey!
Returns a reference to the private key component of this key pair.
Return |
PrivateKey! |
a reference to the private key. |
getPublic
fun getPublic(): PublicKey!
Returns a reference to the public key component of this key pair.
Return |
PublicKey! |
a reference to the public key. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# KeyPair\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nKeyPair\n=======\n\n```\nclass KeyPair : Serializable\n```\n\n|---|----------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [java.security.KeyPair](#) |\n\nThis class is a simple holder for a key pair (a public key and a private key). It does not enforce any security, and, when initialized, should be treated like a PrivateKey.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [KeyPair](#KeyPair(java.security.PublicKey,%20java.security.PrivateKey))`(`publicKey:` `[PublicKey](/reference/kotlin/java/security/PublicKey)!`, `privateKey:` `[PrivateKey](/reference/kotlin/java/security/PrivateKey)!`)` Constructs a key pair from the given public key and private key. |\n\n| Public methods ||\n|-----------------------------------------------------------|----------------------------------------------------------------------------------------------------|\n| [PrivateKey](/reference/kotlin/java/security/PrivateKey)! | [getPrivate](#getPrivate())`()` Returns a reference to the private key component of this key pair. |\n| [PublicKey](/reference/kotlin/java/security/PublicKey)! | [getPublic](#getPublic())`()` Returns a reference to the public key component of this key pair. |\n\nPublic constructors\n-------------------\n\n### KeyPair\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nKeyPair(\n publicKey: PublicKey!, \n privateKey: PrivateKey!)\n```\n\nConstructs a key pair from the given public key and private key.\n\nNote that this constructor only stores references to the public and private key components in the generated key pair. This is safe, because `Key` objects are immutable.\n\n| Parameters ||\n|--------------|-----------------------------------------------------------------------------|\n| `publicKey` | [PublicKey](/reference/kotlin/java/security/PublicKey)!: the public key. |\n| `privateKey` | [PrivateKey](/reference/kotlin/java/security/PrivateKey)!: the private key. |\n\nPublic methods\n--------------\n\n### getPrivate\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getPrivate(): PrivateKey!\n```\n\nReturns a reference to the private key component of this key pair.\n\n| Return ||\n|-----------------------------------------------------------|---------------------------------|\n| [PrivateKey](/reference/kotlin/java/security/PrivateKey)! | a reference to the private key. |\n\n### getPublic\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getPublic(): PublicKey!\n```\n\nReturns a reference to the public key component of this key pair.\n\n| Return ||\n|---------------------------------------------------------|--------------------------------|\n| [PublicKey](/reference/kotlin/java/security/PublicKey)! | a reference to the public key. |"]]