User Tools

Site Tools


nfldb_m2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
nfldb_m2 [2026/05/31 13:56] โ€“ adminnfldb_m2 [2026/06/02 14:18] (current) โ€“ admin
Line 17: Line 17:
   );   );
   });   });
 +  
 +schedule sql
 +  $sql = "SELECT tblGamesBrief.ID as briefID, tblGamesFull.ID as homeID, tblGamesFull.xTeam as homeTeam, tblGamesFull.xDate as xDate, tblGamesFull.xWeek as xWeek, tblGamesFull_1.ID as awayID, tblGamesFull_1.xTeam as awayTeam, (case when (Month(tblGamesFull.xDate)> 5) then Year(tblGamesFull.xDate) else Year(tblGamesFull.xDate) - 1 end) as xYear FROM (tblGamesBrief INNER JOIN tblGamesFull ON tblGamesBrief.xHomeTeam = tblGamesFull.ID) INNER JOIN tblGamesFull AS tblGamesFull_1 ON tblGamesBrief.xVisitingTeam = tblGamesFull_1.ID Where (case when (Month(tblGamesFull.xDate)> 5) then Year(tblGamesFull.xDate) else Year(tblGamesFull.xDate) - 1 end)=$getYear order by tblGamesFull.xDate";
 +  
 +encryption
 +  
 +  network first for start_url
 +  if (event.request.mode === 'navigate') {
 +    event.respondWith(
 +      // 1. Try the network first
 +      fetch(event.request)
 +        .then((response) => {
 +          // Clone the response so we can put one in cache and return the other
 +          const responseToCache = response.clone();
 +          
 +          caches.open(CACHE_NAME).then((cache) => {
 +            cache.put(event.request, responseToCache);
 +          });
 +          
 +          return response;
 +        })
 +        .catch(() => {
 +          // 2. Fallback to cache if network fails (offline)
 +          return caches.match(event.request);
 +        })
 +    );
 +  }
 +  
 +  javascriptasync function encryptData(plaintext, hexKey) {
 +    // 1. Convert hex key to byte array
 +    const keyBuffer = new Uint8Array(hexKey.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
 +    
 +    // 2. Import the raw key into Web Crypto API
 +    const cryptoKey = await crypto.subtle.importKey(
 +        "raw", keyBuffer, { name: "AES-CBC" }, false, ["encrypt"]
 +    );
 +
 +    // 3. Generate a random 16-byte initialization vector (IV)
 +    const iv = crypto.getRandomValues(new Uint8Array(16));
 +    const encoder = new TextEncoder();
 +    const encodedPlaintext = encoder.encode(plaintext);
 +
 +    // 4. Encrypt the data
 +    const ciphertextBuffer = await crypto.subtle.encrypt(
 +        { name: "AES-CBC", iv: iv }, cryptoKey, encodedPlaintext
 +    );
 +
 +    // 5. Convert IV and Ciphertext to Base64
 +    const ivBase64 = btoa(String.fromCharCode(...iv));
 +    const ciphertextBase64 = btoa(String.fromCharCode(...new Uint8Array(ciphertextBuffer)));
 +
 +    // 6. Combine them with a colon separator for transmission
 +    return `${ivBase64}:${ciphertextBase64}`;
 +}
 +
 +  // Execution Example:
 +  encryptData("Hello from the browser!", "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914df1a")
 +    .then(encryptedString => console.log("Send this to PHP:", encryptedString));
 +  Use code with caution.๐Ÿ˜ PHP Decryption (Server)The PHP script accepts the composite Base64 string, splits it   back into the individual IV and ciphertext segments, and decrypts it using the built-in OpenSSL library.php<?php
 +
 +  function decryptData($encryptedString, $hexKey) {
 +    // 1. Convert hex key back to binary
 +    $key = hex2bin($hexKey);
 +
 +    // 2. Split the incoming payload into IV and Ciphertext components
 +    $parts = explode(':', $encryptedString);
 +    if (count($parts) !== 2) {
 +        return false; // Invalid payload structure
 +    }
 +
 +    $iv = base64_decode($parts[0]);
 +    $ciphertext = base64_decode($parts[1]);
 +
 +    // 3. Decrypt using native OpenSSL
 +    $decrypted = openssl_decrypt(
 +        $ciphertext,
 +        'aes-256-cbc',
 +        $key,
 +        OPENSSL_RAW_DATA,
 +        $iv
 +    );
 +
 +    return $decrypted;
 +  }
 +
 +  // Execution Example:
 +  $hexKey = "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914df1a";
 +  $receivedPayload = $_POST['encrypted_data'] ?? 'PASTE_JAVASCRIPT_OUTPUT_HERE';
 +
 +  $decryptedMessage = decryptData($receivedPayload, $hexKey);
 +
 +  if ($decryptedMessage !== false) {
 +    echo "Decryption Successful: " . $decryptedMessage;
 +  } else {
 +    echo "Decryption Failed.";
 +  }
  
nfldb_m2.1780235786.txt.gz ยท Last modified: 2026/05/31 13:56 by admin