请大虾帮写个加密函数
请大虾帮写个加密函数,主要用于URL加密,
本想用MD5的,得是MD5不可逆,想过用base64加密或urlencode编码了,但这两个函数太长了。
请大虾帮自定义一个加密函数,最好不要长于是16位,越小越好,也不要小于8位,怕重复,呵呵。
用于URL传输的,加密后最好是数字或字符。谢谢!
记得是可逆的。
------解决方案--------------------
mcrypt
- PHP code
<?php /* Open the cipher */ $td = mcrypt_module_open('rijndael-256', '', 'ofb', ''); /* Create the IV and determine the keysize length, use MCRYPT_RAND * on Windows instead */ $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM); $ks = mcrypt_enc_get_key_size($td); /* Create key */ $key = substr(md5('very secret key'), 0, $ks); /* Intialize encryption */ mcrypt_generic_init($td, $key, $iv); /* Encrypt data */ $encrypted = mcrypt_generic($td, 'This is very important data'); /* Terminate encryption handler */ mcrypt_generic_deinit($td); /* Initialize encryption module for decryption */ mcrypt_generic_init($td, $key, $iv); /* Decrypt encrypted string */ $decrypted = mdecrypt_generic($td, $encrypted); /* Terminate decryption handle and close module */ mcrypt_generic_deinit($td); mcrypt_module_close($td); /* Show string */ echo trim($decrypted) . "\n"; ?> <div class="clear"> </div>

php替换mcrypt的方法:1、打开相应的php文件;2、找到原来的加密和解密代码;3、使用“openssl_encrypt”以及“openssl_decrypt”方法进行替代即可。

在Python的开发过程中,经常会遇到找不到模块的错误。这个错误的具体表现就是Python在导入模块的时候报出ModuleNotFoundError或者ImportError这两个错误之一。这种错误很困扰,会导致程序无法正常运行,因此在这篇文章里,我们将会探究这个错误的原因及其解决方法。ModuleNotFoundError和ImportError在Pyth

在Java9版本中Java语言引入了一个非常重要的概念:模块(module)。如果对javascript代码模块化管理比较熟悉的小伙伴,看到Java9的模块化管理,应该有似曾相识的感觉。一、什么是Javamodule?与Java中的package有些类似,module引入了Java代码分组的另一个级别。每个这样的分组(module)都包含许多子package包。通过在一个模块的源代码文件package的根部,添加文件module-info.java来声明该文件夹及其子文件夹为一个模块。该文件语法

可逆加密算法(对称加密)加密算法是一种将原始数据转换为加密数据的方法。根据加密算法的不同特征,可以将其分为可逆加密算法和不可逆加密算法。可逆加密算法也称为对称加密算法,其加密和解密过程使用相同的密钥。在这种算法中,加密数据可以通过解密算法还原为原始数据。这种算法通常用于保护数据的机密性,例如保护存储在计算机硬盘上的文件或网络传输的数据。说白了,就是在数据的传输过程中加密,真正在业务中使用的时候,还是用明文。比如,使用AES加密算法对文件进行加密:fromCrypto.CipherimportAE

1.首先确认一下Linux系统内核[root@localhost~]#uname-r-p2.6.18-194.el5i6862.到http://sourceforge.net/projects/linux-ntfs/files/下载对应内核的rpm包如果找不到完全一致的,可以找最相近的。我的就没有找到完全一致的,我下载的是:kernel-module-ntfs-2.6.18-128.1.1.el5-2.1.27-0.rr.10.11.i686.rpm3.安装rpm包rpm-ivhkernel-m

vuex主要包含以下五个部分:State、Getter 、Mutation 、Action 、Module ,下面就给大家介绍Vuex Module-状态仓库分割,希望对需要的朋友有所帮助!

Laravel是一个优秀的PHP框架,它的设计理念是简单、优雅,同时提供了强大的功能和易用的API接口,广受开发者的欢迎。在Laravel框架中,使用LaravelEncryption加密数据非常方便,本文将介绍LaravelEncryption的基本使用方法。什么是LaravelEncryption?LaravelEncryption是Larave

Python的os模块是用于与操作系统进行交互的标准库之一,它提供了许多有用的函数和变量,以便处理文件和目录。下面是一些常见的os模块函数的用法:1.获取当前工作目录:importoscwd=os.getcwd()print(cwd)2.切换当前工作目录:importosos.chdir('/path/to/new/directory')3.列出目录中的所有文件和子目录:importosfiles=os.listdir('/path/to/dire


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
