Hi there,

I have a question in EncryptByPassPhrase.
I am trying to encrypt the source column in the database table PForm. When I run the code it sasys, “Failed to convert parameter value from a String to a Byte[].”
the SourcePath column in the database is varBinary(256) type.
What is the problem over here.

public void AddFormDetails(string ID, string SourcePath)
        {
            string query = @"Insert into PForm(ID, SourcePath) 
                                    Values(@id,EncryptByPassPhrase('AdminApplication',@source)";
            SqlCommand command = new SqlCommand(query, DB.getConnection());

            command.Parameters.Add("@id", SqlDbType.VarChar).Value = ID;
            
            command.Parameters.Add("@source", SqlDbType.VarBinary).Value = SourcePath ;
            
            db.openConnection();
            command.ExecuteNonQuery();
            db.closeConnection();
        }

hey can someone help me with this

thanxxxx

hey can someone help me with this

thanxxxx

hi can someone help me in this
plzzzzzz
thankxx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.