Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Node.js) Read JCEKS Containing Secret KeysDemonstrates how to read a JCEKS keystore file containing symmetric secret keys (for AES, Blowfish, HMAC SHA25, ChaCha, etc.) This example uses the jceks sample file that you may download from Sample JCEKS with Secret Keys The file password is "filePassword". The password for each secret key contained in the JCEKS is "secret". This example requires Chilkat v9.5.0.66 or greater.
var os = require('os'); if (os.platform() == 'win32') { if (os.arch() == 'ia32') { var chilkat = require('@chilkat/ck-node21-win-ia32'); } else { var chilkat = require('@chilkat/ck-node21-win64'); } } else if (os.platform() == 'linux') { if (os.arch() == 'arm') { var chilkat = require('@chilkat/ck-node21-arm'); } else if (os.arch() == 'x86') { var chilkat = require('@chilkat/ck-node21-linux32'); } else { var chilkat = require('@chilkat/ck-node21-linux64'); } } else if (os.platform() == 'darwin') { if (os.arch() == 'arm64') { var chilkat = require('@chilkat/ck-node21-mac-m1'); } else { var chilkat = require('@chilkat/ck-node21-macosx'); } } function chilkatExample() { // IMPORTANT: This example requires Chilkat v9.5.0.66 or greater. // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. var jceks = new chilkat.JavaKeyStore(); var success = jceks.LoadFile("filePassword","qa_data/jks/secretKeys_filePassword.jceks"); if (success !== true) { console.log(jceks.LastErrorText); return; } var keyPassword = "secret"; // Iterate over each secret key and get the key bytes and aliases.. var i = 0; var numSecretKeys = jceks.NumSecretKeys; while (i < numSecretKeys) { console.log("---- Secret Key " + i); console.log("Alias: " + jceks.GetSecretKeyAlias(i)); // Get the secret key bytes in a desired encoding (base64, hex, base64url, etc.) console.log("Key Bytes (hex): " + jceks.GetSecretKey(keyPassword,i,"hex")); console.log("Key Bytes (base64): " + jceks.GetSecretKey(keyPassword,i,"base64")); i = i+1; } // The output: // ---- Secret Key 0 // Alias: aes_key // Key Bytes (hex): CB3632FD12FF3256E0048C100DDE8DEF // Key Bytes (base64): yzYy/RL/MlbgBIwQDd6N7w== // ---- Secret Key 1 // Alias: chacha_key // Key Bytes (hex): B37C73871C7B8F8D488DDE2F1A78CF51B6D74FFAF0E9B338B9609510A4688136 // Key Bytes (base64): s3xzhxx7j41Ijd4vGnjPUbbXT/rw6bM4uWCVEKRogTY= // ---- Secret Key 2 // Alias: hmac_sha256_key // Key Bytes (hex): 3C644B53F904A3BF161D3EAD1364E52EAE6C6EC8C61133B974A2484B894539C0 // Key Bytes (base64): PGRLU/kEo78WHT6tE2TlLq5sbsjGETO5dKJIS4lFOcA= // ---- Secret Key 3 // Alias: blowfish_key // Key Bytes (hex): FFE0574DE04B50F1E2FE79B4160B3B2183ACFF41721C46BFF9764CF24CA40E3C // Key Bytes (base64): /+BXTeBLUPHi/nm0Fgs7IYOs/0FyHEa/+XZM8kykDjw= } chilkatExample(); |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.