CloudLock Documentation

Everything you need to integrate CloudLock into your application

Quick Start

1. Add CloudLock to your HTML

<script src="https://cloudlock.pro/v2.js"></script>

Add this script tag to your HTML. CloudLock will automatically initialize and protect all forms on your page.

2. Install the server package

npm install cloudlock-server

Install the server-side decryption package for your backend.

3. Add decryption middleware

const cloudlock = require('cloudlock-server');
app.use(cloudlock.middleware());

That's it! Your forms are now protected with prime field encryption.

Installation

Browser (CDN)

<!-- Latest version -->
<script src="https://cloudlock.pro/v2.js"></script>

<!-- Or use specific version -->
<script src="https://cloudlock.pro/v1.0.7/cloudlock.min.js"></script>

NPM Package

# Client-side (coming soon)
npm install cloudlock-client

# Server-side decryption
npm install cloudlock-server

Framework Integration

// React
useEffect(() => {
  const script = document.createElement('script');
  script.src = 'https://cloudlock.pro/v2.js';
  document.head.appendChild(script);
}, []);
// Vue
mounted() {
  const script = document.createElement('script');
  script.src = 'https://cloudlock.pro/v2.js';
  document.head.appendChild(script);
}

Configuration

Basic Configuration

// Configure CloudLock (optional)
CloudLock.configure({
  debug: true,              // Enable debug logging
  indicator: {
    enabled: true,          // Show encryption indicator
    position: 'top-right'   // Position of indicator
  },
  analytics: {
    enabled: true,          // Enable analytics (Pro only)
    teamId: 'your-team-id'  // Your team ID
  }
});

Custom Field Patterns

// Add custom field patterns
CloudLock.configure({
  patterns: {
    explicit: /custom-secret-field/i,
    implicit: /my-sensitive-data/i,
    content: {
      customId: /^ID-d{6}$/
    }
  }
});

API Reference

CloudLock Methods

CloudLock.encrypt(data, domain?)

Manually encrypt data using CloudLock.

const encrypted = CloudLock.encrypt('sensitive data');
// Returns: "🔐1.0.7:k:encrypted_base64..."

CloudLock.isEncrypted(value)

Check if a value is encrypted.

const isEnc = CloudLock.isEncrypted('🔐1.0.7:k:data');
// Returns: true

CloudLock.protect(form)

Manually protect a specific form.

const form = document.getElementById('myForm');
CloudLock.protect(form);

Server-side Decryption

const cloudlock = require('cloudlock-server');

// Express middleware
app.use(cloudlock.middleware());

// Manual decryption
const decrypted = cloudlock.decrypt(encryptedData, domain);

Security

Encryption Details

Prime Field: M31

Uses Mersenne prime 2,147,483,647 for field operations

Generator: 7

Primitive root providing full field coverage

Domain Isolation

Each domain receives a unique encryption key

Best Practices

  • Always serve CloudLock over HTTPS
  • Implement rate limiting on your server
  • Validate decrypted data server-side
  • Use Content Security Policy headers

Frequently Asked Questions

Does CloudLock work with SPAs?

Yes! CloudLock automatically detects dynamically added forms. It uses MutationObserver to watch for new forms and protects them automatically.

What fields are encrypted?

CloudLock automatically detects sensitive fields like passwords, emails, credit cards, SSNs, and API keys. You can also configure custom patterns.

Can I use CloudLock with AJAX?

Yes! CloudLock encrypts form data before submission, whether it's a traditional form submit or AJAX request. The encrypted data is in the form fields.

Is the encryption reversible?

Yes, CloudLock uses mathematically reversible encryption based on multiplicative characters in prime fields. Only your server with the correct domain key can decrypt the data.

Need More Help?

Contact our support team or check out our GitHub repository for examples and updates.