Simple sha1 encryption function example implemented by PHP and phpsha1 encryption example

Source: Internet
Author: User
Tags sha1 encryption

Simple sha1 encryption function example implemented by PHP and phpsha1 encryption example

This example describes the sha1 encryption function implemented by PHP. We will share this with you for your reference. The details are as follows:

function encryptTokey($data){     $apikey = 'testapikey111';     $ps1 = sha1($apikey . strtolower($data));     $ps1 = strtoupper($ps1);     $s1 = implode(str_split($ps1, 2), '-');     $ps2 = md5($s1 . $apikey);     $ps2 = strtoupper($ps2);     $token = implode(str_split($ps2, 2), '-');     return $token;}echo encryptTokey('testdata');

Running result:

68-10-98-74-4C-82-74-4B-CC-49-31-98-46-02-EE-8E

PS: if you are interested in encryption and decryption, refer to the online tools on this site:

Online SHA1 encryption tool:
Http://tools.jb51.net/password/sha1encode

Online text encryption and decryption tools (including AES, DES, and RC4 ):
Http://tools.jb51.net/password/txt_encode

Online MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160 encryption tools:
Http://tools.jb51.net/password/hash_md5_sha

Online sha1/shaloud/sha256/sha384/sha512 encryption tool:
Http://tools.jb51.net/password/sha_encode

Online hash/hash algorithm encryption tool:
Http://tools.jb51.net/password/hash_encrypt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.