219 lines
6.6 KiB
HTML
219 lines
6.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Rust WebAssembly Crypto Example</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
.container {
|
|
border: 1px solid #ddd;
|
|
padding: 20px;
|
|
border-radius: 5px;
|
|
margin-bottom: 20px;
|
|
}
|
|
button {
|
|
background-color: #4CAF50;
|
|
border: none;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
text-align: center;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
font-size: 16px;
|
|
margin: 4px 2px;
|
|
cursor: pointer;
|
|
border-radius: 4px;
|
|
}
|
|
button.secondary {
|
|
background-color: #6c757d;
|
|
}
|
|
button.danger {
|
|
background-color: #dc3545;
|
|
}
|
|
input, textarea, select {
|
|
padding: 8px;
|
|
margin: 5px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
width: 80%;
|
|
}
|
|
.result {
|
|
margin-top: 10px;
|
|
padding: 10px;
|
|
background-color: #f5f5f5;
|
|
border-radius: 4px;
|
|
word-break: break-all;
|
|
}
|
|
.key-display {
|
|
font-family: monospace;
|
|
font-size: 12px;
|
|
word-break: break-all;
|
|
}
|
|
.note {
|
|
font-style: italic;
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 15px;
|
|
}
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
font-weight: bold;
|
|
}
|
|
.status {
|
|
padding: 10px;
|
|
margin-bottom: 15px;
|
|
border-radius: 4px;
|
|
}
|
|
.status.logged-in {
|
|
background-color: #d4edda;
|
|
color: #155724;
|
|
}
|
|
.status.logged-out {
|
|
background-color: #f8d7da;
|
|
color: #721c24;
|
|
}
|
|
.hidden {
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Rust WebAssembly Crypto Example</h1>
|
|
|
|
<!-- Login/Space Management Section -->
|
|
<div class="container" id="login-container">
|
|
<h2>Key Space Management</h2>
|
|
|
|
<div id="login-status" class="status logged-out">
|
|
Status: Not logged in
|
|
</div>
|
|
|
|
<div id="login-form">
|
|
<div class="form-group">
|
|
<label for="space-name">Space Name:</label>
|
|
<input type="text" id="space-name" placeholder="Enter space name" />
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="space-password">Password:</label>
|
|
<input type="password" id="space-password" placeholder="Enter password" />
|
|
</div>
|
|
|
|
<div>
|
|
<button id="login-button">Login</button>
|
|
<button id="create-space-button">Create New Space</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="logout-form" class="hidden">
|
|
<div class="form-group">
|
|
<label>Current Space: <span id="current-space-name"></span></label>
|
|
</div>
|
|
<button id="logout-button" class="danger">Logout</button>
|
|
</div>
|
|
|
|
<div class="result" id="space-result">Result will appear here</div>
|
|
</div>
|
|
|
|
<!-- Keypair Management Section -->
|
|
<div class="container" id="keypair-management-container">
|
|
<h2>Keypair Management</h2>
|
|
|
|
<div id="keypair-form">
|
|
<div class="form-group">
|
|
<label for="keypair-name">Keypair Name:</label>
|
|
<input type="text" id="keypair-name" placeholder="Enter keypair name" />
|
|
<button id="create-keypair-button">Create Keypair</button>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="select-keypair">Select Keypair:</label>
|
|
<select id="select-keypair">
|
|
<option value="">-- Select a keypair --</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="result" id="keypair-management-result">Result will appear here</div>
|
|
<div class="key-display" id="selected-pubkey-display"></div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Message Signing</h2>
|
|
<div>
|
|
<textarea id="sign-message" placeholder="Enter message to sign" rows="3">Hello, this is a test message to sign</textarea>
|
|
<button id="sign-button">Sign Message</button>
|
|
</div>
|
|
<div class="result" id="signature-result">Signature will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Signature Verification</h2>
|
|
<div>
|
|
<textarea id="verify-message" placeholder="Enter message to verify" rows="3"></textarea>
|
|
<textarea id="verify-signature" placeholder="Enter signature to verify" rows="3"></textarea>
|
|
<button id="verify-button">Verify Signature</button>
|
|
</div>
|
|
<div class="result" id="verify-result">Verification result will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Symmetric Encryption</h2>
|
|
<div>
|
|
<textarea id="encrypt-message" placeholder="Enter message to encrypt" rows="3">This is a secret message that will be encrypted</textarea>
|
|
<button id="encrypt-button">Generate Key & Encrypt</button>
|
|
</div>
|
|
<div class="key-display" id="sym-key-display"></div>
|
|
<div class="note" id="nonce-display">Note: Nonce is handled internally</div>
|
|
<div class="result" id="encrypt-result">Encrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Symmetric Decryption</h2>
|
|
<div>
|
|
<input type="text" id="decrypt-key" placeholder="Enter key (hex)" />
|
|
<div class="note">Note: Nonce is now extracted automatically from the ciphertext</div>
|
|
<textarea id="decrypt-ciphertext" placeholder="Enter ciphertext (hex)" rows="3"></textarea>
|
|
<button id="decrypt-button">Decrypt</button>
|
|
</div>
|
|
<div class="result" id="decrypt-result">Decrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Password-Based Encryption</h2>
|
|
<div>
|
|
<div class="form-group">
|
|
<label for="password-encrypt-password">Password:</label>
|
|
<input type="password" id="password-encrypt-password" placeholder="Enter password" />
|
|
</div>
|
|
<textarea id="password-encrypt-message" placeholder="Enter message to encrypt" rows="3">This message will be encrypted with a password</textarea>
|
|
<button id="password-encrypt-button">Encrypt with Password</button>
|
|
</div>
|
|
<div class="result" id="password-encrypt-result">Encrypted data will appear here</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<h2>Password-Based Decryption</h2>
|
|
<div>
|
|
<div class="form-group">
|
|
<label for="password-decrypt-password">Password:</label>
|
|
<input type="password" id="password-decrypt-password" placeholder="Enter password" />
|
|
</div>
|
|
<textarea id="password-decrypt-ciphertext" placeholder="Enter ciphertext (hex)" rows="3"></textarea>
|
|
<button id="password-decrypt-button">Decrypt with Password</button>
|
|
</div>
|
|
<div class="result" id="password-decrypt-result">Decrypted data will appear here</div>
|
|
</div>
|
|
|
|
<script type="module" src="./js/index.js"></script>
|
|
</body>
|
|
</html> |