Wednesday, 15 February 2023

URL encode

 URL  encode

 

 <?php

namespace App\Http\Controllers\API;
 
use Log; use DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class EncodeController extends Controller
{       
    // UrlEncode
    public function urlencode(Request $request)
    {
        try            
        {  
            $myvar = DB::table('cl_master_category')
            ->select('cl_master_category.category_id', 'cl_master_category.category_name', 'cl_master_category.status', 'cl_master_category.color_code')
            ->get();
            
            $ciphering = "AES-256-CBC";    
            $encryption_key = env('ENCRYPTION_KEY');            
            $encryption_iv = env('ENCRYPTION_IV');
            
            $myencoding = openssl_encrypt($myvar, $ciphering,$encryption_key, 0, $encryption_iv);  
            
            return response()->json(['success' => true ,'encoded'=>$myencoding], 200);
           
        }
        catch (\Exception\Database\QueryException $e)
        {
            Log::info('Query: '.$e->getSql());
            Log::info('Query: Bindings: '.$e->getBindings());
            Log::info('Error: Code: '.$e->getCode());
            Log::info('Error: Message: '.$e->getMessage());

            return response()->json(['success' => false , 'message' => 'Database Server Error. Please try again later.'], 500);
        }
        catch (\Exception $e)
        {
            Log::info('Error: Code: '.$e->getCode());
            Log::info('Error: Message: '.$e->getMessage());

            return response()->json(['success' => true , 'message' => 'Internal Server Error. Please try again later.'], 500);
        }
    }
   
}


********************************************************************
Nextjs code

import React from "react";

import CryptoJS from "crypto-js";

const test = () => { 

  let keytext =  "25c6c7ff35b9979b151f2136cd13b0ff"

  let encrypted = "Nb7g0tuktmBmEwUbGrMabzMHlUTN/uyDPg5coE0AHTgmkvkxmwYxapvMu4IaZoCEXphDN+A+PfcMRGGdPso1vbKWJU9X1Yr+oh/eBRobD6hkG4BWJIxnVW79LSkK8WBfieMy05j2FxQH8GzXlPJ9KtcaMcxU2Zj8YERpko2Q8bpcWAlbQVDHXHRaYLMjoR7QvUz2OYqY3CNyLQgXnoc70q5JyAT+eC036Mx/zBnjA16HeVI5xI1MFQ4aFEddd58XwICngKZcuahG0tdUcZ8Z4XgZnmMzMrt+QeunhPg+IQGZhPhL4ZqH2CMYMy2TDtIqClRiAytjekMIcyJErYjVSYPnvGuBQqXiwW23QM69XWMvY0WFmZXXnKQPiwcRUSh3UgEPmbk6Dx023KnL6uw6Maq7/8BzaPzKCJO31gxyXk17NEh+by/59/UDaaLSKnB4fFRu1G/qa+Rg5n5l01XK2uNWITqKne3xWleACeMN652ZVhU1dWPwiWKkwI6hjbCg8m9UtRKw57rq3d6Jt/pN+SUdLJXbIjcTd9oxWlltSUDv4LlstWIlRIx9i6B+SEOMWtEvJvVfDn2DrBtxdo+02SH7ZjNhNi8CEFEHQybPxNBd2KNaiAWyIHgiqCZwmoCDjgPoQh2bWj33jPOVGvqPsCfuFfW10RieWK8yMtZHV2/W16DX3+j3Urt7Cb5o0KvG2+va3+YvTZ123c3a/+UkR+S2odrhEku041VUahIx15Zlhi80ffPn0ngX6E4wDa5QkKAL34kZbQJnZPnzD0P4QOHl34cpn5ZZVP8HsoWAXrAiTM033qG976w43Ld1ewxGG5VhSGRgNHj9CQ42l5+7GQ=="

  // let decrypted = "";

  let ivtext ="1234567891011121"

  

  const key = CryptoJS.enc.Utf8.parse(keytext);

  const iv = CryptoJS.enc.Utf8.parse(ivtext);  

  var decrypted = CryptoJS.AES.decrypt(encrypted, key, {

    iv: iv,

    mode: CryptoJS.mode.CBC,

  });

  text = CryptoJS.enc.Utf8.stringify(decrypted)

  console.log("decrypt", CryptoJS.enc.Utf8.stringify(decrypted));

  return (

    <>

      <div> {text}</div>

      {/ <div>encrypted Text : {encrypted}</div> /}

      {/ <div>Decrypted Text : {decrypted}</div> /}

    </>

  );

};

export default test;

 

 

Machine Learning - Potato Leaf Disease Prediction

Step 1: import numpy as np import pandas as pd import splitfolders import matplotlib.pyplot as plt import tensorflow as tf from tensorflow i...