Generate Key Pair
The "Generate Key Pairs" component allows users to generate new Stellar Wallet key pairs.
The component includes fields for displaying the generated wallet address and secret key.
Keep your secretkey secure and never share it!
Features
- Generates new Stellar Wallet key pairs.
- Displays the generated wallet address and secret key.
Additional Resources
Stellar employs public key cryptography for secure transactions. Each Stellar account has a keypair containing a public key and a secret key. The public key is shareable and used by others to identify your account and verify authorized transactions, similar to an email address. In contrast, the secret key is private and acts like a password, providing ownership and access to your account. It should never be shared with anyone to maintain account security.
C#
Install the Pakana.Stellar.Components NuGet package via the NuGet Package Manager Console.
.Net8.0 or greater is required.
dotnet add package Pakana.Stellar.Components
StellarSDK Dependency will install automatically
<pakana.stellar.components.Pages.GenerateKeyPair/>
@page "/GenerateKeyPair"
@rendermode InteractiveAuto
<h1>Stellar Key Pair Generator</h1>
<button onclick="generateKeyPair()">Generate Key Pair</button>
<div id="keyPairDisplay" style="margin-top: 20px;">
<!-- Key pair will be displayed here -->
</div>
@code{
string publicKey { set; get; } = "";
string secretKey { set; get; } = "";
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/8.0.0/stellarsdk.min.js"></script>
<script src="your-file-path/js/generateKeyPair.js"></script>
Javascript
We've provided simple HTML and JavaScript that can be used in your project as partial-components or be customized and integrated into your existing codebase.
*Current Version as of 2024-24-02*
<script src="https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/11.2.2/stellar-sdk.js"></script>
<script>
function generateKeyPair() {
// Check if StellarSdk is properly loaded
if (typeof StellarSdk === 'undefined') {
console.error('Stellar SDK not loaded.');
return;
}
// Generate a new Stellar key pair
const keyPair = StellarSdk.Keypair.random();
// Display the key pair on the webpage
const publicKey = keyPair.publicKey();
const secretKey = keyPair.secret();
const keyPairDisplay = document.getElementById('keyPairDisplay');
keyPairDisplay.innerHTML = `
<p><strong>Public Key:</strong> ${publicKey}</p>
<p><strong>Secret Key:</strong> ${secretKey}</p>
<p><strong>⚠️ Important:</strong> Keep your secret
key secure and never share it!</p>
`;
}
</script>
<body>
<h1>Stellar Key Pair Generator</h1>
<button onclick="generateKeyPair()">Generate Key Pair</button>
<div id="keyPairDisplay" style="margin-top: 20px;">
<!-- Key pair will be displayed here -->
</div>
</body>