mcrypt

C#, Java, PHP, Python和Javascript几种语言的AES加密解密实现

北战南征 提交于 2020-04-25 01:43:47
特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过。如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处: http://www.cnblogs.com/mao2080/ 1、问题描述   在与C同事调试的时候发现,Java加密的文件,C语言解析不了,后面找了很多才找到解决方案。 2、操作方法   1、Java加密解密 import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import org.junit.Test; ... @Test public void testCrossLanguageEncrypt() throws Exception{ System.out.println(encrypt()); System.out.println(desEncrypt()); } public static String encrypt() throws Exception { try { String data = "Test String"; String key = "1234567812345678"; String iv = "1234567812345678"

Mac 下使用 homebrew 切换不同版本 php

我只是一个虾纸丫 提交于 2020-04-21 23:54:57
最近刚切换回 Mac 下进行开发,所以写了比较多的 Mac 环境部署之类的文章。今天需要重新切换一下本地的开发环境。原本想直接在当前环境下开发, 毕竟 Mac 自带了 PHP 环境,今天需要新添一个扩展 freetype ,需要重新编译一遍 PHP。 由于这个扩展是核心内置扩展,没法通过phpize来编译安装。 解决办法只有一个,就是找到PHP的安装源码重新编译一下,在编译的时候,加上–with-freetype-dir。 但是要知道的一个事 —— Mac上PHP是内置的,根本就找不到它的安装源码在哪! 所以需要重新编译一遍 PHP,并且不影响 Mac 当前的 PHP 环境。 Mac 下软件的安装和管理,当然离不开 homebrew 了。 安装 php 不同版本 brew install php54 brew install php55 brew install php56 brew install php70 安装新版本时,你很大几率上会被提醒,php 已经安装了 xxx 版本了,你需要先 unlink 原先的版本。于是就是下面的这个命令了。先 unlink 再安装。 安装后自然就 link 好了。 常规切换 通过 brew 安装的 php 可以通过brew link和brew unlink来切换不同版本。 brew list brew unlink php56 brew

How can I install a pecl extension like mcrypt in DDEV-Local's web container?

会有一股神秘感。 提交于 2020-04-16 02:27:47
问题 In PHP 7.2 and higher the mcrypt extension is no longer available, but my project depends on it. I know that the project shouldn't be using something as ancient as mcrypt, but I don't have any say in this. I know that mcrypt was removed from PHP7.2+ but is still in pecl. What can I do for this project to support php-mcrypt in 7.2 and higher? 回答1: DDEV-Local supports custom Dockerfiles, so you can add almost anything you want to the web container. This .ddev/web-build/Dockerfile will install

How to Install mcrypt PHP module

拥有回忆 提交于 2020-03-25 12:40:07
问题 I am using Linux Mint 19.1. My PHP configuration is like below I am getting below error while I am trying to install mcrypt . 回答1: Try out using these commands To install the dependencies : sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install php7.2-dev sudo apt-get -y install libmcrypt-dev Once the dependencies have been installed, you can install mcrypt with the command: sudo pecl install mcrypt-1.0.1 来源: https://stackoverflow.com/questions/60372913/how-to

How to Install mcrypt PHP module

浪尽此生 提交于 2020-03-25 12:39:27
问题 I am using Linux Mint 19.1. My PHP configuration is like below I am getting below error while I am trying to install mcrypt . 回答1: Try out using these commands To install the dependencies : sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install php7.2-dev sudo apt-get -y install libmcrypt-dev Once the dependencies have been installed, you can install mcrypt with the command: sudo pecl install mcrypt-1.0.1 来源: https://stackoverflow.com/questions/60372913/how-to

Issue with encrypt and decrypt a word docx file in php

孤街浪徒 提交于 2020-01-30 06:58:04
问题 I tried to use php mcrypt TripleDES for encryption for docx format files. When i tried to decrypt the file, i am getting the error as follows. The Office Open XML file file_name cannot be opened because there are problems with the contents. Here is the below code function Encrypt($source,$key,$iv) { $cipher = mcrypt_module_open(MCRYPT_3DES, '', 'cbc', ''); mcrypt_generic_init($cipher, $key, $iv); $result = mcrypt_generic($cipher, $source); mcrypt_generic_deinit($cipher); return $result; }

mcrypt 7.1 deprecated / 7.2+ removal

送分小仙女□ 提交于 2020-01-30 06:16:08
问题 I have been following information on SO about generating random strings using mcrypt_create_iv() and have some example code over at 3v4l.org. After reading the PHPWiki all mycrypt_* functions will show a depreceated warning but it does not specify what will be used in 7.2/8.0 that replaces these functions. Since it states it will be removed in 7.2/8.0, what will be used to replace IV's? I do not use this function in my software for encryption and decryption. I only use it for safe/retrievel

PHP decryption with mcrypt returns unintelligible text instead of original plaintext

跟風遠走 提交于 2020-01-23 19:25:15
问题 I am just trying to encrypt and decrypt a string. But when I output the decrypted string I only get: �� ^����V��_��n�.ZZ��Ǐ��:�2�� My code: function encrypt($string, $secret_key = "ATRTHTRAGSFRSGTS") { $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $secret_key, $string, MCRYPT_MODE_CBC, $iv); } function decrypt($string, $secret_key = "ATRTHTRAGSFRSGTS") { $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT

PHP decryption with mcrypt returns unintelligible text instead of original plaintext

馋奶兔 提交于 2020-01-23 19:23:37
问题 I am just trying to encrypt and decrypt a string. But when I output the decrypted string I only get: �� ^����V��_��n�.ZZ��Ǐ��:�2�� My code: function encrypt($string, $secret_key = "ATRTHTRAGSFRSGTS") { $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $secret_key, $string, MCRYPT_MODE_CBC, $iv); } function decrypt($string, $secret_key = "ATRTHTRAGSFRSGTS") { $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT