SM-Smart API Documentation

Integrate encryption into your application

Base URL

https://cdn.jsdelivr.net/gh/SM-Smart-SK/encryptor-js@main/api.json

GET Get Service Metadata

/system-config.dat

Načítava dynamické konfiguračné parametre pre šifrovacie jadro SM-Smart.

Internal Fetch Call
// Dáta sú načítavané asynchrónne do privátnej pamäte aplikácie
// prístup k priamemu mapovaniu je obmedzený cez systémové API
fetch('.../system-config.dat').then(res => res.json());

Client-side Integration

Ak chcete použiť SM-Smart šifrovanie vo svojej aplikácii, vložte tento kód do vášho JavaScript súboru.

Full Integration Example (JavaScript)
// 1. Define the URL for your GitHub config (with cache-busting)
const SM_API_URL = 'https://cdn.jsdelivr.net/gh/SM-Smart-SK/encryptor-js@main/system-config.dat?v=' + Date.now();

/**
* 2. Function to encrypt text using downloaded configuration data
* @param {string} plainText - The text to be encrypted
*/
async function smEncrypt(plainText) {
try {
// Fetch keys from your API/GitHub
const response = await fetch(SM_API_URL);
const config = await response.json();

// Merge alphabet, numbers, and symbols into a single lookup map
const keyMap = { ...config.alphabet, ...config.numbers, ...config.symbols };

// Text normalization and encryption logic
return plainText
.normalize("NFD").replace(/[\u0300-\u036f]/g, "") // Remove accents/diacritics
.toUpperCase()
.split(/\s+/) // Split into individual words
.map(word =>
word.split('').map(char => keyMap[char] || char).join('-')
)
.join('--'); // Join words with double dash

} catch (err) {
console.error("SM-Smart API Error:", err);
return null;
}
}
// 3. Usage example:
smEncrypt("Hello world 2026").then(result => {
console.log("Encrypted result:", result);
});
Add this to your HTML file:

                    <script src="script.js"></script>

<input type="text" id="userInput" placeholder="Enter text to encrypt">

<button onclick="spustitSifrovanie()">Encrypt</button>

<p id="result"></p>

<script>
// This function will be called when the user clicks the "Encrypt" button
async function spustitSifrovanie() {
const text = document.getElementById('userInput').value;
const vysledokElement = document.getElementById('result');
vysledokElement.innerText = "Encrypting...";
// Call the encryption function from script.js
const sifra = await smEncrypt(text);
if (sifra) {
vysledokElement.innerText = sifra;
} else {
vysledokElement.innerText = "Error while encrypting!";
}
}
</script>

Error Handling

The API returns standard HTTP status codes. Errors are returned as JSON:

{
"success": false,
"error": "Invalid input",
"code": 400,
"message": "Text parameter is required"
}

Status Codes:

  • 200 - Success
  • 400 - Bad Request
  • 429 - Rate Limited
  • 500 - Server Error