Generate secure hashes and HMAC signatures.
curl -X GET "https://mockly.me/hash/securemydata?algorithm=sha256"
// Generate a hash of user input
const userInput = document.getElementById('password').value;
fetch(`https://mockly.me/hash/${encodeURIComponent(userInput)}?algorithm=sha256`)
.then(response => response.json())
.then(data => {
console.log('Original:', data.original);
console.log('Algorithm:', data.algorithm);
console.log('Hashed:', data.hashed);
// Store the hash for verification
localStorage.setItem('password_hash', data.hashed);
});
import requests
def hash_text(text, algorithm="sha256"):
"""Generate a hash of the provided text"""
response = requests.get(
f"https://mockly.me/hash/{text}",
params={"algorithm": algorithm}
)
data = response.json()
return data
# Test with different algorithms
algorithms = ["md5", "sha1", "sha256", "sha512"]
text = "secure_password123"
for algo in algorithms:
result = hash_text(text, algo)
print(f"{algo.upper()}: {result['hashed']}")
{
"original": "hello",
"algorithm": "sha256",
"hashed": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
}
curl -X GET "https://mockly.me/hmac?data=verify-me&key=my-secret-key&algorithm=sha256"
// Create an HMAC signature for data authentication
const data = JSON.stringify({ userId: 1234, action: "payment" });
const secretKey = "API_SECRET_KEY_123";
// Get HMAC to verify data integrity
fetch(`https://mockly.me/hmac?data=${encodeURIComponent(data)}&key=${encodeURIComponent(secretKey)}`)
.then(response => response.json())
.then(result => {
// Attach the signature to the request headers
const headers = {
'Content-Type': 'application/json',
'X-HMAC-Signature': result.signature
};
// Send authenticated request
fetch('https://api.example.com/process-payment', {
method: 'POST',
headers: headers,
body: data
});
});
import requests
import json
def get_hmac_signature(data, key, algorithm="sha256"):
"""Generate an HMAC signature for data authentication"""
params = {
"data": data,
"key": key,
"algorithm": algorithm
}
response = requests.get("https://mockly.me/hmac", params=params)
return response.json()
# Data to be authenticated
payload = json.dumps({"user_id": 123, "timestamp": 1689422587})
api_key = "your_secret_key_here"
# Get HMAC signature
result = get_hmac_signature(payload, api_key)
print(f"Signature: {result['signature']}")
# In a real application, you would verify the signature
print(f"Verification code: {result['verification_example']}")
{
"data": "hello",
"key": "secret",
"algorithm": "sha256",
"signature": "f8b4f424a7a8c9fa936435851a7b4ba5579e8047f8f7d15db1a2d981547a7cd9",
"verification_example": "hmac.new('secret'.encode(), 'hello'.encode(), hashlib.sha256).hexdigest() == 'f8b4f424a7a8c9fa936435851a7b4ba5579e8047f8f7d15db1a2d981547a7cd9'"
}
Generate and work with JSON Web Tokens for authentication and authorization.
curl -X GET "https://mockly.me/jwt"
// Generate a sample JWT token for UI demo
fetch('https://mockly.me/jwt')
.then(response => response.json())
.then(data => {
// Store the JWT token
localStorage.setItem('demo_token', data.token);
// Display token information
document.getElementById('token').textContent = data.token;
// Display decoded payload
const decodedPayload = JSON.stringify(data.payload, null, 2);
document.getElementById('decoded-token').textContent = decodedPayload;
// Show expiration information
const expiryTime = new Date(data.expires_at).toLocaleString();
document.getElementById('token-expiry').textContent = expiryTime;
});
import requests
from datetime import datetime
# Get a sample JWT token
response = requests.get("https://mockly.me/jwt")
data = response.json()
print(f"JWT Token: {data['token']}")
print(f"\nDecoded Header: {data['header']}")
print(f"\nDecoded Payload: {data['payload']}")
# Check if token is expired
expires_at = datetime.fromisoformat(data['expires_at'].replace('Z', '+00:00'))
current_time = datetime.now()
if current_time > expires_at:
print("\nToken has expired")
else:
print(f"\nToken is valid until: {expires_at}")
print(f"Time remaining: {expires_at - current_time}")
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLTM0NTYiLCJuYW1lIjoiRXhhbXBsZSBVc2VyIiwiaWF0IjoxNjg5NDIyNTg3LCJleHAiOjE2ODk0MjYxODcsImlzcyI6Im1vY2tseS5tZSJ9.D8LJBXtQQbq5XTSG1YXt4bhw8SCIqfM2_rcUUL9Bib4",
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"sub": "user-3456",
"name": "Example User",
"iat": 1689422587,
"exp": 1689426187,
"iss": "mockly.me"
},
"expires_at": "2023-07-15T16:49:47.582942"
}
curl -X GET "https://mockly.me/xor?data=confidential&key=mykey"
// Basic obfuscation of data with XOR
const data = "confidential_data_123";
const key = "mysecretkey";
// Encode the data
fetch(`https://mockly.me/xor?data=${encodeURIComponent(data)}&key=${encodeURIComponent(key)}`)
.then(response => response.json())
.then(result => {
console.log('Original data:', result.original);
console.log('Encoded data:', result.encoded);
// Store encoded data
localStorage.setItem('obfuscated_data', result.encoded);
// To decode, you need to use the same key and re-encode
// (XOR is its own inverse with the same key)
});
import requests
import base64
def xor_encode(data, key):
"""Encode data with XOR using a key"""
params = {
"data": data,
"key": key
}
response = requests.get("https://mockly.me/xor", params=params)
return response.json()
def xor_decode(encoded_data, key):
"""Decode XOR-encoded data using the same key"""
# Decode the base64 string
decoded_base64 = base64.b64decode(encoded_data).decode()
# XOR again with the same key (XOR is its own inverse)
params = {
"data": decoded_base64,
"key": key
}
response = requests.get("https://mockly.me/xor", params=params)
return response.json()["original"]
# Test encoding and decoding
data = "sensitive_information"
key = "secret123"
# Encode the data
encoded = xor_encode(data, key)
print(f"Encoded: {encoded['encoded']}")
# Decode the data
# In a real implementation, you would handle the base64 decoding
# and XOR operation directly rather than calling the API again
print(f"Original data: {data}")
{
"original": "secret",
"key": "abc123",
"encoded": "ERkQGxABCQ==",
"note": "The result is base64 encoded after XOR operation"
}
Generate secure random values, UUIDs, and colors for testing and development.
# Get a random string
curl -X GET "https://mockly.me/random?type=string"
# Get a random name
curl -X GET "https://mockly.me/random?type=name"
# Get a random emoji
curl -X GET "https://mockly.me/random?type=emoji"
// Get different random values for a demo
async function populateRandomData() {
// Get random username
const nameResponse = await fetch('https://mockly.me/random?type=name');
const nameData = await nameResponse.json();
document.getElementById('username').textContent = nameData.value;
// Get random number for ID
const numResponse = await fetch('https://mockly.me/random?type=number');
const numData = await numResponse.json();
document.getElementById('user-id').textContent = numData.value;
// Get random emoji for avatar
const emojiResponse = await fetch('https://mockly.me/random?type=emoji');
const emojiData = await emojiResponse.json();
document.getElementById('avatar').textContent = emojiData.value;
}
// Run when page loads
document.addEventListener('DOMContentLoaded', populateRandomData);
// Refresh button
document.getElementById('refresh-data').addEventListener('click', populateRandomData);
import requests
def get_random(type_value):
"""Get a random value of the specified type"""
response = requests.get(f"https://mockly.me/random?type={type_value}")
return response.json()["value"]
# Generate test user data
def generate_test_user():
username = get_random("name")
user_id = get_random("number")
password = get_random("string")
return {
"username": username,
"user_id": user_id,
"password": password
}
# Generate multiple test users
test_users = [generate_test_user() for _ in range(5)]
print("Generated test users:")
for i, user in enumerate(test_users, 1):
print(f"User {i}: {user['username']} (ID: {user['user_id']})")
{
"type": "string",
"value": "x7Lp2QrZ9"
}
curl -X GET "https://mockly.me/color"
// Generate a color scheme from a random color
function generateColorScheme() {
fetch('https://mockly.me/color')
.then(response => response.json())
.then(data => {
// Update color display
const colorBox = document.getElementById('primary-color');
colorBox.style.backgroundColor = data.hex;
colorBox.textContent = data.hex;
// Set text color based on accessibility
colorBox.style.color = data.accessibility.best_text_color;
// Show color information
document.getElementById('color-name').textContent = data.name;
document.getElementById('color-rgb').textContent = data.rgb;
// Set up accessibility info
const accessMsg = data.accessibility.wcag_aa_compliant ?
'✓ WCAG AA Compliant' : '✗ Not WCAG AA Compliant';
document.getElementById('accessibility').textContent = accessMsg;
});
}
// Generate on page load and when button clicked
document.addEventListener('DOMContentLoaded', generateColorScheme);
document.getElementById('new-color').addEventListener('click', generateColorScheme);
import requests
def generate_color_palette(num_colors=5):
"""Generate a color palette with complementary colors"""
colors = []
for _ in range(num_colors):
response = requests.get("https://mockly.me/color")
color_data = response.json()
colors.append({
"hex": color_data["hex"],
"name": color_data["name"],
"accessibility": color_data["accessibility"]
})
return colors
# Generate a color palette for a design project
palette = generate_color_palette()
print("Color Palette:")
for i, color in enumerate(palette, 1):
print(f"{i}. {color['hex']} - {color['name']}")
print(f" Best text color: {color['accessibility']['best_text_color']}")
print(f" WCAG compliant: {color['accessibility']['wcag_aa_compliant']}")
print()
{
"hex": "#4287f5",
"rgb": "rgb(66,135,245)",
"name": "Blue",
"accessibility": {
"luminance": 0.42,
"best_text_color": "#FFFFFF",
"wcag_aa_compliant": true
}
}
# Get a v4 (random) UUID
curl -X GET "https://mockly.me/uuid?version=4"
# Get a v1 (time-based) UUID
curl -X GET "https://mockly.me/uuid?version=1"
// Generate a v4 UUID for unique identification
fetch('https://mockly.me/uuid?version=4')
.then(response => response.json())
.then(data => {
// Use for unique identifiers
const id = data.uuid;
console.log('Generated UUID:', id);
// Example: Create a new record with this UUID
const newRecord = {
id: id,
name: 'New Item',
created: new Date().toISOString()
};
// Save to local storage
localStorage.setItem(`item_${id}`, JSON.stringify(newRecord));
});
import requests
def get_uuid(version=4, namespace=None):
"""Generate a UUID of the specified version"""
params = {"version": version}
if namespace:
params["namespace"] = namespace
response = requests.get("https://mockly.me/uuid", params=params)
return response.json()
# Generate UUIDs for a database migration
print("Generating UUIDs for database migration...")
# Get a v1 UUID (timestamp-based) for logging
v1_uuid = get_uuid(version=1)
print(f"Timestamp UUID: {v1_uuid['uuid']}")
print(f"Generated at: {v1_uuid['timestamp']}")
# Get multiple v4 UUIDs for records
records = []
for i in range(3):
v4_uuid = get_uuid(version=4)
records.append({
"id": v4_uuid['uuid'],
"name": f"Record {i+1}"
})
print("\nGenerated records:")
for record in records:
print(f"- {record['id']} : {record['name']}")
{
"uuid": "f8b4f424-a7a8-c9fa-9364-35851a7b4ba5",
"version": 4,
"description": "Random UUID",
"timestamp": null,
"namespace": null
}
Utilities for password strength evaluation and certificate generation.
curl -X GET "https://mockly.me/password/strength?password=MySecureP%40ssw0rd"
// Password strength checker for registration form
document.getElementById('password').addEventListener('input', function() {
const password = this.value;
// Don't check empty passwords
if (!password) {
document.getElementById('password-strength').textContent = '';
return;
}
// Check password strength with API
fetch(`https://mockly.me/password/strength?password=${encodeURIComponent(password)}`)
.then(response => response.json())
.then(data => {
// Update the strength meter
const strengthMeter = document.getElementById('strength-meter');
strengthMeter.value = data.score;
// Update strength text
const strengthText = document.getElementById('password-strength');
strengthText.textContent = `Strength: ${data.strength}`;
// Add color based on strength
strengthText.className = ''; // Reset classes
if (data.strength === 'very weak' || data.strength === 'weak') {
strengthText.classList.add('text-red-600');
} else if (data.strength === 'moderate') {
strengthText.classList.add('text-yellow-600');
} else {
strengthText.classList.add('text-green-600');
}
// Show feedback
const feedbackList = document.getElementById('password-feedback');
feedbackList.innerHTML = '';
data.feedback.forEach(item => {
const li = document.createElement('li');
li.textContent = item;
li.className = item.startsWith('✓') ? 'text-green-600' : 'text-gray-600';
feedbackList.appendChild(li);
});
});
});
import requests
def check_password_strength(password):
"""Check the strength of a password"""
params = {"password": password}
response = requests.get("https://mockly.me/password/strength", params=params)
return response.json()
# Test a set of passwords
passwords = [
"password123",
"qwerty",
"SecurePassword1",
"Tr0ub4dor&3"
]
print("Password Strength Analysis:")
print("-" * 50)
for password in passwords:
result = check_password_strength(password)
print(f"Password: {result['password']}")
print(f"Strength: {result['strength']} (Score: {result['score']}/10)")
print(f"Est. crack time: {result['crack_time_estimate']}")
print("Feedback:")
for item in result['feedback']:
print(f" {item}")
print("-" * 50)
{
"password": "**********",
"score": 7,
"strength": "strong",
"feedback": [
"✓ Contains uppercase letters",
"✓ Contains lowercase letters",
"✓ Contains numbers",
"✓ Contains special characters"
],
"crack_time_estimate": "128 minutes"
}
curl -X GET "https://mockly.me/ssl/certificate"
// Get mock SSL certificate info for UI demo
fetch('https://mockly.me/ssl/certificate')
.then(response => response.json())
.then(cert => {
// Display certificate details
document.getElementById('cert-subject').textContent =
`${cert.subject.organization} (${cert.subject.common_name})`;
document.getElementById('cert-issuer').textContent =
`${cert.issuer.organization}`;
document.getElementById('cert-validity').textContent =
`Valid from ${cert.validity.not_before} to ${cert.validity.not_after}`;
document.getElementById('cert-days').textContent =
`${cert.validity.days_remaining} days remaining`;
// Set certificate status based on days remaining
const daysRemaining = cert.validity.days_remaining;
let statusColor = 'text-green-600';
let statusText = 'Valid';
if (daysRemaining < 0) {
statusColor = 'text-red-600';
statusText = 'Expired';
} else if (daysRemaining < 30) {
statusColor = 'text-orange-600';
statusText = 'Expiring Soon';
}
const statusElement = document.getElementById('cert-status');
statusElement.textContent = statusText;
statusElement.className = statusColor;
});
import requests
from datetime import datetime
def get_certificate_info():
"""Get SSL certificate information"""
response = requests.get("https://mockly.me/ssl/certificate")
return response.json()
# Get certificate information
cert = get_certificate_info()
# Print certificate summary
print("SSL Certificate Information")
print("=" * 50)
print(f"Subject: {cert['subject']['common_name']}")
print(f"Organization: {cert['subject']['organization']}")
print(f"Issuer: {cert['issuer']['organization']}")
print(f"Serial: {cert['serial_number']}")
print(f"Valid from: {cert['validity']['not_before']}")
print(f"Valid until: {cert['validity']['not_after']}")
print(f"Days left: {cert['validity']['days_remaining']}")
# Check if certificate is expiring soon
if cert['validity']['days_remaining'] < 30:
print("\nWARNING: Certificate expiring in less than 30 days!")
# Display alternative names
print("\nSubject Alternative Names:")
for name in cert['extensions']['subject_alternative_names']:
print(f"- {name}")
{
"version": 3,
"serial_number": "a1b2c3d4e5f6",
"signature_algorithm": "sha256WithRSAEncryption",
"issuer": {
"country": "US",
"organization": "Mock Certificate Authority",
"common_name": "Mock CA"
},
"validity": {
"not_before": "2023-06-15 08:23:45 UTC",
"not_after": "2024-06-14 08:23:45 UTC",
"days_remaining": 334
},
"subject": {
"country": "US",
"state": "California",
"locality": "San Francisco",
"organization": "Example Company",
"common_name": "*.example.com"
},
"public_key": {
"algorithm": "RSA",
"key_size": 2048,
"fingerprint_sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
},
"extensions": {
"key_usage": ["Digital Signature", "Key Encipherment"],
"extended_key_usage": ["TLS Web Server Authentication", "TLS Web Client Authentication"],
"subject_alternative_names": [
"example.com",
"www.example.com",
"api.example.com"
],
"basic_constraints": "CA:FALSE",
"crl_distribution_points": ["http://crl.mockca.com/MockCA.crl"]
}
}
Interactive Security Demo
Try out these security utilities to generate hashes, tokens, and test password strength for your applications.
Password Strength Checker
Feedback:
Meet Mockly Assistant
Your AI assistant for API testing, debugging and code generation. Access the power of mockly.me directly in ChatGPT.
- Generate code examples in your preferred language
- Get guidance for request/response handling and formatting
- Supercharged by ChatGPT Plus from OpenAI
"How do I send data to a POST endpoint"
"I can show you how to structure your request with headers and JSON — here's a code example..."