Testing Environment: Our tools are currently under heavy testing. You may experience slower performance or temporary issues.

🛡️

Text Encrypt Decrypt Tool

Encrypt and decrypt text using AES, RSA, and other secure algorithms

Encrypt Text

Characters: 0 | Bytes: 0
Very Strong: Advanced Encryption Standard - Industry standard

🔐 Encryption Algorithms

AES:Most Secure (Recommended)
TripleDES:Good Security (Legacy)
Rabbit:Fast Stream Cipher
RC4:Fast but Deprecated

🔑 Security Tips

• Use strong, unique secret keys (32+ characters)
• AES is the gold standard for encryption
• Never share your secret keys publicly
• Test decryption before relying on encryption
• Consider using key derivation for passwords

🛡️ Encryption Security Tips

  • Strong Keys: Use long, random secret keys with mixed characters
  • Key Management: Store keys securely and separately from encrypted data
  • Algorithm Choice: AES is recommended for maximum security
  • Test Thoroughly: Always verify decryption works before trusting encryption
  • Backup Keys: Losing your key means losing your data permanently

About Text Encryption & Decryption

Text encryption converts readable text into unreadable ciphertext using cryptographic algorithms, ensuring data confidentiality and security. Our tool supports multiple encryption methods including AES-256, RSA, and symmetric/asymmetric encryption schemes.

  • AES-256 symmetric encryption for fast, secure data protection
  • RSA asymmetric encryption for key exchange and digital signatures
  • Multiple cipher modes: CBC, GCM, ECB for different security needs
  • Secure key generation and management
  • Base64 encoding for safe text transmission

Encryption Algorithms

Symmetric Encryption

  • AES-256: Advanced Encryption Standard (industry standard)
  • AES-192: Medium security with good performance
  • AES-128: Fast encryption for less sensitive data
  • ChaCha20: Modern stream cipher alternative
  • 3DES: Legacy triple DES encryption

Asymmetric Encryption

  • RSA: Rivest-Shamir-Adleman (1024-4096 bit keys)
  • ECC: Elliptic Curve Cryptography (smaller keys)
  • DSA: Digital Signature Algorithm
  • EdDSA: Edwards-curve signatures
  • Diffie-Hellman: Key exchange protocol

Advertisement

AdSense Banner Ad Placeholder

Frequently Asked Questions

What's the difference between AES and RSA encryption?

AES is symmetric encryption (same key for encrypt/decrypt), faster and suitable for large data. RSA is asymmetric (public/private key pair), slower but enables secure key exchange and digital signatures without sharing secret keys.

Which encryption strength should I choose?

For most applications, AES-256 provides excellent security. AES-128 is sufficient for less sensitive data and faster performance. RSA-2048 is minimum recommended, RSA-4096 for high-security applications.

Is it safe to encrypt sensitive data online?

For maximum security, use client-side encryption (data encrypted in your browser before transmission). Our tool processes data locally when possible. For highly sensitive data, consider offline encryption tools.

What happens if I lose my encryption key?

Without the correct key, encrypted data cannot be recovered. Always securely backup your keys and consider key escrow for critical business data. Use strong, memorable passwords or secure key management systems.

Encryption Examples

AES-256 Encryption:

Plaintext:
Hello World! This is my secret message.
Key (32 bytes):
mySecretKey12345678901234567890
Encrypted (Base64):
U2FsdGVkX1+vupppZksvRf5pq5g5XjFRIipRkwB0K4FeUaRw...

RSA Encryption Process:

1. Key Generation
Size: 2048-bit RSA keypair
Public: For encryption
Private: For decryption
2. Encryption
Input: Plaintext + Public Key
Output: Encrypted ciphertext
Padding: OAEP recommended
3. Decryption
Input: Ciphertext + Private Key
Output: Original plaintext
Verification: Integrity check

Sponsored Content

AdSense Square Ad Placeholder

Encryption Implementation

JavaScript Encryption/Decryption:

class TextEncryption {
  constructor() {
    this.supportedAlgorithms = {
      'AES-256-GCM': { keyLength: 32, ivLength: 12 },
      'AES-192-GCM': { keyLength: 24, ivLength: 12 },
      'AES-128-GCM': { keyLength: 16, ivLength: 12 },
      'AES-256-CBC': { keyLength: 32, ivLength: 16 },
      'AES-192-CBC': { keyLength: 24, ivLength: 16 },
      'AES-128-CBC': { keyLength: 16, ivLength: 16 }
    };
  }
  
  // Encrypt text using AES
  async encryptAES(plaintext, password, algorithm = 'AES-256-GCM') {
    try {
      if (!this.supportedAlgorithms[algorithm]) {
        return {
          success: false,
          error: `Unsupported algorithm: ${algorithm}`
        };
      }
      
      const config = this.supportedAlgorithms[algorithm];
      
      // Derive key from password
      const key = await this.deriveKey(password, config.keyLength);
      
      // Generate random IV
      const iv = crypto.getRandomValues(new Uint8Array(config.ivLength));
      
      // Encrypt the data
      const encoder = new TextEncoder();
      const data = encoder.encode(plaintext);
      
      const cryptoKey = await crypto.subtle.importKey(
        'raw',
        key,
        { name: algorithm.split('-')[0] },
        false,
        ['encrypt']
      );
      
      const encrypted = await crypto.subtle.encrypt(
        {
          name: algorithm.includes('GCM') ? 'AES-GCM' : 'AES-CBC',
          iv: iv
        },
        cryptoKey,
        data
      );
      
      // Combine IV and encrypted data
      const result = new Uint8Array(iv.length + encrypted.byteLength);
      result.set(iv);
      result.set(new Uint8Array(encrypted), iv.length);
      
      // Encode to Base64
      const base64Result = this.arrayBufferToBase64(result);
      
      return {
        success: true,
        encrypted: base64Result,
        algorithm: algorithm,
        keyLength: config.keyLength * 8,
        ivLength: config.ivLength,
        format: 'Base64',
        metadata: {
          timestamp: new Date().toISOString(),
          version: '1.0'
        }
      };
      
    } catch (error) {
      return {
        success: false,
        error: error.message
      };
    }
  }
  
  // Decrypt AES encrypted text
  async decryptAES(encryptedData, password, algorithm = 'AES-256-GCM') {
    try {
      if (!this.supportedAlgorithms[algorithm]) {
        return {
          success: false,
          error: `Unsupported algorithm: ${algorithm}`
        };
      }
      
      const config = this.supportedAlgorithms[algorithm];
      
      // Decode from Base64
      const encrypted = this.base64ToArrayBuffer(encryptedData);
      
      // Extract IV and ciphertext
      const iv = encrypted.slice(0, config.ivLength);
      const ciphertext = encrypted.slice(config.ivLength);
      
      // Derive the same key from password
      const key = await this.deriveKey(password, config.keyLength);
      
      const cryptoKey = await crypto.subtle.importKey(
        'raw',
        key,
        { name: algorithm.split('-')[0] },
        false,
        ['decrypt']
      );
      
      // Decrypt the data
      const decrypted = await crypto.subtle.decrypt(
        {
          name: algorithm.includes('GCM') ? 'AES-GCM' : 'AES-CBC',
          iv: iv
        },
        cryptoKey,
        ciphertext
      );
      
      // Convert back to text
      const decoder = new TextDecoder();
      const plaintext = decoder.decode(decrypted);
      
      return {
        success: true,
        decrypted: plaintext,
        algorithm: algorithm,
        originalLength: plaintext.length
      };
      
    } catch (error) {
      return {
        success: false,
        error: 'Decryption failed - incorrect password or corrupted data'
      };
    }
  }
  
  // Generate RSA key pair
  async generateRSAKeyPair(keySize = 2048) {
    try {
      const keyPair = await crypto.subtle.generateKey(
        {
          name: 'RSA-OAEP',
          modulusLength: keySize,
          publicExponent: new Uint8Array([1, 0, 1]), // 65537
          hash: 'SHA-256'
        },
        true,
        ['encrypt', 'decrypt']
      );
      
      // Export keys
      const publicKey = await crypto.subtle.exportKey('spki', keyPair.publicKey);
      const privateKey = await crypto.subtle.exportKey('pkcs8', keyPair.privateKey);
      
      return {
        success: true,
        publicKey: this.arrayBufferToBase64(publicKey),
        privateKey: this.arrayBufferToBase64(privateKey),
        keySize: keySize,
        format: 'Base64',
        algorithm: 'RSA-OAEP',
        hash: 'SHA-256'
      };
      
    } catch (error) {
      return {
        success: false,
        error: error.message
      };
    }
  }
  
  // Encrypt with RSA public key
  async encryptRSA(plaintext, publicKeyBase64) {
    try {
      // Import public key
      const publicKeyBuffer = this.base64ToArrayBuffer(publicKeyBase64);
      const publicKey = await crypto.subtle.importKey(
        'spki',
        publicKeyBuffer,
        {
          name: 'RSA-OAEP',
          hash: 'SHA-256'
        },
        false,
        ['encrypt']
      );
      
      // Encrypt data
      const encoder = new TextEncoder();
      const data = encoder.encode(plaintext);
      
      const encrypted = await crypto.subtle.encrypt(
        'RSA-OAEP',
        publicKey,
        data
      );
      
      return {
        success: true,
        encrypted: this.arrayBufferToBase64(encrypted),
        algorithm: 'RSA-OAEP',
        hash: 'SHA-256',
        format: 'Base64'
      };
      
    } catch (error) {
      return {
        success: false,
        error: error.message
      };
    }
  }
  
  // Decrypt with RSA private key
  async decryptRSA(encryptedData, privateKeyBase64) {
    try {
      // Import private key
      const privateKeyBuffer = this.base64ToArrayBuffer(privateKeyBase64);
      const privateKey = await crypto.subtle.importKey(
        'pkcs8',
        privateKeyBuffer,
        {
          name: 'RSA-OAEP',
          hash: 'SHA-256'
        },
        false,
        ['decrypt']
      );
      
      // Decrypt data
      const encryptedBuffer = this.base64ToArrayBuffer(encryptedData);
      const decrypted = await crypto.subtle.decrypt(
        'RSA-OAEP',
        privateKey,
        encryptedBuffer
      );
      
      const decoder = new TextDecoder();
      const plaintext = decoder.decode(decrypted);
      
      return {
        success: true,
        decrypted: plaintext,
        algorithm: 'RSA-OAEP'
      };
      
    } catch (error) {
      return {
        success: false,
        error: 'Decryption failed - invalid key or corrupted data'
      };
    }
  }
  
  // Derive key from password using PBKDF2
  async deriveKey(password, keyLength, iterations = 100000) {
    const encoder = new TextEncoder();
    const passwordBuffer = encoder.encode(password);
    
    // Generate random salt
    const salt = crypto.getRandomValues(new Uint8Array(16));
    
    // Import password as key material
    const keyMaterial = await crypto.subtle.importKey(
      'raw',
      passwordBuffer,
      'PBKDF2',
      false,
      ['deriveBits']
    );
    
    // Derive key
    const derivedKey = await crypto.subtle.deriveBits(
      {
        name: 'PBKDF2',
        salt: salt,
        iterations: iterations,
        hash: 'SHA-256'
      },
      keyMaterial,
      keyLength * 8
    );
    
    return new Uint8Array(derivedKey);
  }
  
  // Secure random key generation
  generateRandomKey(length = 32) {
    const key = crypto.getRandomValues(new Uint8Array(length));
    return {
      key: Array.from(key),
      keyHex: Array.from(key).map(b => b.toString(16).padStart(2, '0')).join(''),
      keyBase64: this.arrayBufferToBase64(key),
      length: length,
      bits: length * 8
    };
  }
  
  // Utility: Array Buffer to Base64
  arrayBufferToBase64(buffer) {
    const bytes = new Uint8Array(buffer);
    let binary = '';
    for (let i = 0; i < bytes.byteLength; i++) {
      binary += String.fromCharCode(bytes[i]);
    }
    return btoa(binary);
  }
  
  // Utility: Base64 to Array Buffer
  base64ToArrayBuffer(base64) {
    const binaryString = atob(base64);
    const bytes = new Uint8Array(binaryString.length);
    for (let i = 0; i < binaryString.length; i++) {
      bytes[i] = binaryString.charCodeAt(i);
    }
    return bytes;
  }
  
  // Simple Caesar cipher (for educational purposes)
  encryptCaesar(text, shift = 3) {
    return text.replace(/[a-zA-Z]/g, char => {
      const start = char <= 'Z' ? 65 : 97;
      return String.fromCharCode((char.charCodeAt(0) - start + shift) % 26 + start);
    });
  }
  
  // Decrypt Caesar cipher
  decryptCaesar(text, shift = 3) {
    return this.encryptCaesar(text, 26 - shift);
  }
  
  // ROT13 encoding/decoding
  rot13(text) {
    return text.replace(/[a-zA-Z]/g, char => {
      const start = char <= 'Z' ? 65 : 97;
      return String.fromCharCode((char.charCodeAt(0) - start + 13) % 26 + start);
    });
  }
  
  // Base64 encoding/decoding
  base64Encode(text) {
    return btoa(unescape(encodeURIComponent(text)));
  }
  
  base64Decode(base64) {
    try {
      return decodeURIComponent(escape(atob(base64)));
    } catch (error) {
      throw new Error('Invalid Base64 encoding');
    }
  }
  
  // XOR cipher
  encryptXOR(text, key) {
    let result = '';
    for (let i = 0; i < text.length; i++) {
      const textChar = text.charCodeAt(i);
      const keyChar = key.charCodeAt(i % key.length);
      result += String.fromCharCode(textChar ^ keyChar);
    }
    return btoa(result);
  }
  
  decryptXOR(encryptedText, key) {
    const text = atob(encryptedText);
    let result = '';
    for (let i = 0; i < text.length; i++) {
      const textChar = text.charCodeAt(i);
      const keyChar = key.charCodeAt(i % key.length);
      result += String.fromCharCode(textChar ^ keyChar);
    }
    return result;
  }
  
  // Analyze encryption strength
  analyzeStrength(algorithm, keySize) {
    const analysis = {
      algorithm: algorithm,
      keySize: keySize,
      strength: 'Unknown',
      recommendation: '',
      breakTime: 'Unknown'
    };
    
    if (algorithm.includes('AES-256')) {
      analysis.strength = 'Very Strong';
      analysis.breakTime = '2^255 years (practically unbreakable)';
      analysis.recommendation = 'Excellent choice for all security needs';
    } else if (algorithm.includes('AES-128')) {
      analysis.strength = 'Strong';
      analysis.breakTime = '2^127 years (very secure)';
      analysis.recommendation = 'Good for most applications';
    } else if (algorithm.includes('RSA') && keySize >= 2048) {
      analysis.strength = 'Strong';
      analysis.breakTime = 'Decades with current technology';
      analysis.recommendation = 'Secure for current standards';
    } else if (algorithm === 'Caesar') {
      analysis.strength = 'Very Weak';
      analysis.breakTime = 'Minutes (26 possibilities)';
      analysis.recommendation = 'Only for educational purposes';
    }
    
    return analysis;
  }
  
  // Encrypt with multiple algorithms (layered encryption)
  async encryptLayered(plaintext, passwords, algorithms = ['AES-256-GCM']) {
    let currentText = plaintext;
    const layers = [];
    
    for (let i = 0; i < algorithms.length; i++) {
      const algorithm = algorithms[i];
      const password = passwords[i] || passwords[0];
      
      const result = await this.encryptAES(currentText, password, algorithm);
      
      if (!result.success) {
        return result;
      }
      
      layers.push({
        layer: i + 1,
        algorithm: algorithm,
        result: result.encrypted
      });
      
      currentText = result.encrypted;
    }
    
    return {
      success: true,
      encrypted: currentText,
      layers: layers.length,
      algorithms: algorithms,
      note: 'Decrypt in reverse order with corresponding passwords'
    };
  }
}

// Usage examples
const encryption = new TextEncryption();

// AES Encryption
console.log('AES Encryption:');
const plaintext = 'This is my secret message!';
const password = 'myStrongPassword123';
const encrypted = await encryption.encryptAES(plaintext, password, 'AES-256-GCM');
console.log(encrypted);

// AES Decryption
if (encrypted.success) {
  console.log('\nAES Decryption:');
  const decrypted = await encryption.decryptAES(encrypted.encrypted, password, 'AES-256-GCM');
  console.log(decrypted);
}

// RSA Key Generation
console.log('\nRSA Key Generation:');
const keyPair = await encryption.generateRSAKeyPair(2048);
console.log(keyPair);

// Simple ciphers
console.log('\nSimple Ciphers:');
console.log('Caesar:', encryption.encryptCaesar('Hello World', 5));
console.log('ROT13:', encryption.rot13('Hello World'));
console.log('Base64:', encryption.base64Encode('Hello World'));

console.log('Encryption tools ready!');
            

Encryption Algorithm Comparison

Symmetric (AES):

✓ Very fast encryption/decryption
✓ Excellent for large data
✓ Battle-tested security
✗ Key distribution challenge
✗ Same key for encrypt/decrypt

Asymmetric (RSA):

✓ Secure key exchange
✓ Digital signatures
✓ No shared secret needed
✗ Much slower than AES
✗ Limited message size

Hybrid Approach:

✓ RSA for key exchange
✓ AES for data encryption
✓ Best of both worlds
✓ Used in TLS/SSL
~ More complex implementation

Encryption Security Best Practices

  • Use Strong Passwords: Long, complex passwords with mixed characters
  • Secure Key Storage: Never hardcode keys, use secure key management
  • Choose Right Algorithm: AES-256 for data, RSA-2048+ for keys
  • Use Random IVs: Always generate fresh initialization vectors
  • Implement Properly: Use established libraries, avoid custom crypto
  • Regular Key Rotation: Change encryption keys periodically
  • Test Decryption: Always verify you can decrypt before relying on encryption

Common Use Cases

  • Securing sensitive documents and files
  • Password and credential protection
  • Database encryption and security
  • Email and message encryption
  • API key and token protection
  • Legal document confidentiality
  • Personal data privacy compliance
  • Secure communication channels

Advertisement

AdSense Bottom Ad Placeholder