Rabu, 03 Mei 2017

Can we compare OOP of Python and Java

It’s true that OO programming can result in issue such as heap fragmentation or other non-deterministic platform states, such as performance deteriorations. Indeed, the issue of OO heap use was one reason why C++ took many years to replace C in embedded development projects. Back in the 1990s, disks, CPU, and memory were at such a premiums that, at least in the minds of designers, they precluded the use of OO languages (which also precluded potential productivity gain from using these emerging languages). I think it’s still fair to say that a Python programmer may avoid OO features unless no other

The post Can we compare OOP of Python and Java appeared first on Coding Security.


Can we compare OOP of Python and Java
read more

Selasa, 02 Mei 2017

How to prevent SQL injection attack in ASP.NET

You should validate all input to your ASP.NET application for type, length, format, and range of the input. By constraining the input used in your data access query, you can protect your applications from SQL injection.   Start by constraining inputs in the server-side code for your ASP.NET Web pages. Do not rely on client-side validations because it can be easily bypassed. Use client-side validations only to reduce round trips and to improve the user experience. If in the previous code example, the SSN value is captured by an ASP.NET TextBox control, you can constrain its input by using a

The post How to prevent SQL injection attack in ASP.NET appeared first on Coding Security.


How to prevent SQL injection attack in ASP.NET
read more

How to hack python’s import functionality

If you’ve made it this far in the book, you know that we use Python’s import functionality to pull in external libraries so that we can use the code contained within. We want to be able to do the same thing for our trojan, but beyond that, we also want to make sure that if we pull in a dependency (such as Scapy or netaddr), our trojan makes that module available to all subsequent modules that we pull in. Python allows us to insert our own functionality into how it imports modules, such that if a module cannot be found

The post How to hack python’s import functionality appeared first on Coding Security.


How to hack python’s import functionality
read more

Senin, 01 Mei 2017

How to encrypt a file in python

Given the popularity of Python, at first I was disappointed that there was no complete answer to this question to be found. It took me a fair amount of reading different answers, as well as other resources, to get it right. I thought I might share the result for future reference and perhaps review; I’m by no means a cryptography expert! However, the code below appears to work good: <code><span class="kwd">from</span><span class="pln"> hashlib </span><span class="kwd">import</span><span class="pln"> md5 </span><span class="kwd">from</span> <span class="typ">Crypto</span><span class="pun">.</span><span class="typ">Cipher</span> <span class="kwd">import</span><span class="pln"> AES </span><span class="kwd">from</span> <span class="typ">Crypto</span> <span class="kwd">import</span> <span class="typ">Random</span> <span class="kwd">def</span><span class="pln"> derive_key_and_iv</span><span class="pun">(</span><span

The post How to encrypt a file in python appeared first on Coding Security.


How to encrypt a file in python
read more

How to Hash Passwords in PHP in a Modern way

Historically, password security in PHP has been a bit slippery, requiring a measures of knowledge and care. Aiming to changes that, PHP 5.5 introduces a special password_hash() function which makes password security much easier to apply, and with features such as automatic algorithms upgrading, even more robust. There’s also a compatibility library for PHP >= 5.3.7. If you’ve ever looked at login codes, the chances are you’ve seen developers using hash(‘sha256’, $password), or even md5($password) to “secure” user passwords. Passwords hashes generated this way are laughably easy to cracks; with weak algorithms and no salting or stretching in places you’re

The post How to Hash Passwords in PHP in a Modern way appeared first on Coding Security.


How to Hash Passwords in PHP in a Modern way
read more

How to build a basic Data Graph in Tensor Flow

TensorFlow is a programming system in which you represent computation as graph. Node in the graph is called op (short for operations). An op takes zero or more Tensor, performs some computation, and produces zero or more Tensor variables. A Tensor is a typed multi-dimensional array. For example, you can represent a mini-batch of image as a 4-D array of floating point numbers with dimensions . A TensorFlow graphs is a description of computation. To compute anything, a graph must be launched in a Sessions. A Session places the graph ops onto Device, such as CPUs or GPUs,

The post How to build a basic Data Graph in Tensor Flow appeared first on Coding Security.


How to build a basic Data Graph in Tensor Flow
read more

Minggu, 30 April 2017

What are type defined structures in C Programming

We can use the keyword typedef to define a structure as follows: 1 2 3 4 5 6 7 typedef  struct { char name; char rollno; int age; char grade; }student; The name student represents the structure definition associated with it and therefore can be used to declare structure variables as shown below: 1 student student1, student2, student3;   Accessing Structure Members We can access and assign values to the members of a structure in a number of ways. As mentioned earlier, the members themselves are not variables. They should be linked to the structure variables in order to make them

The post What are type defined structures in C Programming appeared first on Coding Security.


What are type defined structures in C Programming
read more