Monday, February 16, 2026

Create and Insert N rows in sql without user interface

 To insert bulk data for testing purpose we can use below query. this query create the table and insert the rows and if required delete the table too.

CREATE TABLE TEST1 (TEST_ID INT IDENTITY(1,1), Name varchar(50), InsDate datetime)


SET IDENTITY_INSERT TEST1 ON;


DECLARE @numRows int,@i int

SET @numRows = 10000

SET @i=1

Declare @Prefix varchar(50) = '_';

WHILE @i<@numRows

BEGIN

Set @Prefix += Cast(@i as varchar(50));

if RIGHT(Cast(@i as varchar(50)), 1) = '0' Set @Prefix = '_';

    INSERT TEST1(TEST_ID,Name,InsDate) SELECT @i,('Murli' + @Prefix),Getdate()

    SET @i=@i+1

END

SET IDENTITY_INSERT TEST1 OFF;


SELECT * FROM TEST1

--DROP TABLE TEST1




Get Latest Active table Name

 Get the latest activity happed on which table name either insert, delete or update.


SELECT 

    t.name AS TableName,

    us.last_user_update

FROM 

    sys.dm_db_index_usage_stats AS us

INNER JOIN 

    sys.tables AS t ON t.object_id = us.object_id

WHERE 

    us.database_id = DB_ID()

ORDER BY 

    us.last_user_update DESC;

Thursday, December 4, 2025

RSA Encryption and Decryption using Private and Public Key, client and server side

RSA Encryption and Decryption using Private and Public Key, client and server side

Here i used two approach 

1. Server Side Encryption (using Public Key) and Server Side Decryption (using Private Key)


using System;
using System.Security.Cryptography;
using System.Text;

public partial class RSA_RSAEncDec : System.Web.UI.Page
{
    string publicKey = "";
    string privateKey = "";


    /*
     * Very Use full Site to develop this functionality
    //https://raskeyconverter.azurewebsites.net/XmlToPem?handler=ConvertPEM
    // For Encryption we user Private key PEM like below sample public key format i.e.  
    -----BEGIN PUBLIC KEY-----
    MIIBIjANBgkqhki....
-----END PUBLIC KEY-----

    For Decryption we required XMl file hence generate using the PEM and result like this..
    xpuS70fWBZv.....AQAB

+m+08g5NTiFXrh5f0...

ywUa2jNho8BFlQobo.....59OegfABWdD9tH4Dn7....B1t1AKlSBYQnQ....v4iZ7IpuX4yc....YC5TWCHX2duUR0a.....
*/ protected void Page_Load(object sender, EventArgs e) { string PreFix = @"C:\Users\murdhusi\Downloads\Biometric (2)\Biometric\Murli\"; publicKey = System.IO.File.ReadAllText(PreFix + @"RSApublicKeyM.txt"); privateKey = System.IO.File.ReadAllText(PreFix + @"RSAprivateKeyM.txt"); } protected void btnEncrypt_Click(object sender, EventArgs e) { txtencrypt.Text = GenerateKeyAndEncrypt(); } protected void btnDecrypt_Click(object sender, EventArgs e) { txtdecrypt.Text = GetKeyandDecrypt(Convert.FromBase64String(txtencrypt.Text)); } #region For Encryption private string GenerateKeyAndEncrypt() { // Generate RSA key pair using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { // Convert the data to bytes string data = txtplain.Text;// "Hello, RSA! MURLi"; //lblMessage.Text += ("
Orignal data: " + data); byte[] dataBytes = Encoding.UTF8.GetBytes(data); // Encrypt the data using the public key byte[] encryptedData = EncryptData(dataBytes, publicKey); string encData = Convert.ToBase64String(encryptedData); // Store or transmit the encrypted data //lblMessage.Text += ("
Encrypted data: " + encData); return encData; } } static byte[] EncryptData(byte[] dataBytes, string publicKey) { //if (true) { using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { // Import the recipient's public key rsa.FromXmlString(publicKey); // Encrypt the data using the public key byte[] encryptedData = rsa.Encrypt(dataBytes, true); return encryptedData; } } } #endregion #region For Decryption private string GetKeyandDecrypt(byte[] encData) { string originalData = ""; string privateKeyXml = ""; // Retrieve the encrypted data byte[] encryptedData = null; // Get the encrypted data privateKeyXml = privateKey; encryptedData = encData; // Create an instance of RSACryptoServiceProvider using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { // Import the private key rsa.FromXmlString(privateKeyXml); // Decrypt the data using the private key byte[] decryptedData = rsa.Decrypt(encryptedData, true); // Convert the decrypted data back to its original form originalData = Encoding.UTF8.GetString(decryptedData); // Display the decrypted data //lblMessage.Text += ("
Decrypted data: " + originalData); } return originalData; } #endregion }

2. Client Side Encryption (using Public Key) and Server Side Decryption (using Private Key)

<script src="https://cdn.jsdelivr.net/npm/jsencrypt@latest/bin/jsencrypt.min.js"></script>

    <script src="js/jsencrypt.min.js"></script>


<!--Your custom script that uses JSEncrypt-->

<script type="text/javascript">

    // Define the encryption function with a single parameter (the data to be encrypted).

    function encrypt(data) {

        //debugger;

        var encrypt = new JSEncrypt(); // Create a new instance of the JSEncrypt library.


        public_key = `-----BEGIN PUBLIC KEY-----

MIIBIjANBgkqhkiG9w.....

-----END PUBLIC KEY-----`;

        

        encrypt.setPublicKey(public_key); // Set the public key for the encryption library.

        var encrypted = encrypt.encrypt(data); // Use the encrypt method of the library to encrypt the data.


        //console.log("encrypted Text: ", encrypted);

        return encrypted; // Return the encrypted data.

    }


let encData = encrypt("Text for encryption");

</script>


Download Sample Code from here 

Friday, October 31, 2025

Prototype Pollution Fixes


Follow below step to fix the prototype pollution fix. To Fix this issue include below shared JS file next to jQuery Library.

Prototype Pollution Fix

FYI Below image

Tuesday, July 22, 2025

Some Git Command

git init

git clone https://murlidIndigo@bitbucket.org/indigoconsultingpublicis/hdfc_dcemi_file_extract_order_service.git

git status

git add .         [Add all files]

git commit -m "Commit Message"  [For Commit the files]

git push  [Push changes on repository]

git switch UAT [Change branch]

git fetch [Get Files from Repository of all branches]

git rm -r --cached [Remove caching]

Thursday, April 10, 2025

Read XMl File data With namespace and without namespace

 

Suppose xml files is avaialble like this with namespace

<?xml version="1.0" encoding="UTF-8"?> <Document xmlns="http://abcd.org/onmags/schema"> <AuthReq> <MyData> Hi How are you </MyData> </AuthReq> </Document>

.Net Sample Code looks like this

#region With Namespace XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("/Sample/request.xml")); var nms = new XmlNamespaceManager(doc.NameTable); nms.AddNamespace("nm", "http://abcd.org/onmags/schema"); XmlNode node = doc.DocumentElement.SelectSingleNode("/nm:Document/nm:AuthReq", nms); //XmlNode node = doc.DocumentElement.SelectSingleNode("/Document/AuthReq"); string request = node.InnerText.ToString(); #endregion =================================================================

Suppose xml files is avaialble like this without namespace

<?xml version="1.0" encoding="UTF-8"?> <Document> <AuthReq> <MyData> Hi How are you </MyData> </AuthReq> </Document>

.Net Sample Code looks like this

#region With Namespace XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("/Sample/request.xml")); XmlNode node = doc.DocumentElement.SelectSingleNode("/Document/AuthReq"); string request = node.InnerText.ToString(); #endregion

Monday, March 3, 2025

Get Validation Error Message, Page.Isvaild False Section, BaseValidator, get server side error message

if you wanted to know the route cause of error message then we can write below code in aso.net 

Get Validation Error Message, Page.Isvaild False Section, BaseValidator,  get server side error message

 foreach (BaseValidator validator in Page.Validators)

            {

                if (validator.Enabled && !validator.IsValid)

                {

                    // Put a breakpoint here

                    string clientID = validator.ClientID;

                    string aa = validator.ErrorMessage;

                }

            }