http://security.stackexchange.com/questions/5586/why-do-people-think-that-this-is-bad-way-to-hash-passwords
Q:
Well, please tell me, what's wrong with this code
$password = "hello";;
$password = md5($password);
for($i=1;$i<20;$i++){
$password = md5($password);
}
Showing posts with label PTechnique. Show all posts
Showing posts with label PTechnique. Show all posts
Sunday, July 24, 2011
Test-Driven Development Is Not Slower
Hello, my name is Matt Honeycutt, and I am addicted to Test Driven
Development. I’ve been “using” for about 5 years now. It started out
with a little innocent unit testing and Test Later Development, but I
quickly found that the increased productivity caused by TDD to be too
alluring, and I succumbed. Now I’m using all the time. I use at work.
I use at home. I just can’t stop. People don’t really understand the
risks. There’s this myth that TDD is slower, that it makes you less
productive, but that’s so not true. Read on, and I’ll help you
understand why.
NOTE: This post is an extended version of a comment I left in reply to an anonymous commenter on Mike Hadlow’s “I Don’t Have Time For Unit Tests” post. I encourage you to go read his post, because Mike has some good insights that I won’t repeat here.
NOTE: This post is an extended version of a comment I left in reply to an anonymous commenter on Mike Hadlow’s “I Don’t Have Time For Unit Tests” post. I encourage you to go read his post, because Mike has some good insights that I won’t repeat here.
Labels:
Programming,
PTechnique
Wednesday, April 6, 2011
Max recursive depth
Max recursive depth
Khi viết hàm kiểu đệ quy, nếu gọi đệ quy quá nhiều lần sẽ bị tràn stack và dẫn đến kết quả trả về sai(thậm chí là crash chương trình). Số lần tối đa gọi đệ quy phụ thuộc vào độ lớn của stack. Trong Unix/Linux, có thể sử dụng lệnh ulimit -a trong terminal để xem stack mà OS cấp cho người dùng là bao nhiêu.(có thể thay đổi được size stack!)
VD:
VD với hàm tính giai thừa viết theo kiểu đệ quy bình thường, khi gọi để tính factorial(1000) đã báo max recursive depth exceeds (trong Python)
Vậy khi viết chương trình, nên tránh viết dưới kiểu đệ quy mà hãy viết theo kiểu tuyến tính để tránh lỗi này xảy ra hoặc chỉ viết đệ quy cho các hàm gọi ít lần.
Khi viết hàm kiểu đệ quy, nếu gọi đệ quy quá nhiều lần sẽ bị tràn stack và dẫn đến kết quả trả về sai(thậm chí là crash chương trình). Số lần tối đa gọi đệ quy phụ thuộc vào độ lớn của stack. Trong Unix/Linux, có thể sử dụng lệnh ulimit -a trong terminal để xem stack mà OS cấp cho người dùng là bao nhiêu.(có thể thay đổi được size stack!)
VD:
hvnsweeting@HVNBBZ:~$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 20
file size (blocks, -f) unlimited
pending signals (-i) 16382
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192 => 8 MB
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
VD với hàm tính giai thừa viết theo kiểu đệ quy bình thường, khi gọi để tính factorial(1000) đã báo max recursive depth exceeds (trong Python)
Vậy khi viết chương trình, nên tránh viết dưới kiểu đệ quy mà hãy viết theo kiểu tuyến tính để tránh lỗi này xảy ra hoặc chỉ viết đệ quy cho các hàm gọi ít lần.
Labels:
Programming,
PTechnique
Subscribe to:
Posts (Atom)