Merge pull request #262 from lengyijun/master

crypto sample: split into 4 functions