Test and explore the library's features in this interactive playground
Configure SaltyKeys with custom settings:
// Default configuration
SaltyKeys.config = {
urlPattern: /codepen\.io\/[^/]+\/(?:pen|debug|fullpage|fullembedgrid)\/([^?#]+)/,
cacheEnabled: true,
environment: 'codepen'
};
For this demo, we'll simulate a CodePen environment:
Enter your API key to generate a salted version:
Decode a salted key to get the original API key:
Change the simulated URL to test key validation across contexts:
Configure a custom URL pattern for non-CodePen environments:
Extract metadata from a salted key:
Change the environment setting to affect key handling:
// Example usage of SaltyKeys.js
const apiKey = 'my-secret-api-key-123';
const saltedKey = SaltyKeys.generateSaltedKey(apiKey);
console.log('Salted Key:', saltedKey);
// Later, when you need the original API key:
const originalKey = SaltyKeys.getApiKey(saltedKey);
if (originalKey) {
// Use the original API key
console.log('Original Key:', originalKey);
} else {
console.warn('Failed to retrieve the API key');
}