我尝试在我的docker镜像中安装mcrypt php:7.2-apache
.因此,我使用文档中的RUN-Command并在此处回答,但是我收到此错误:
error: /usr/src/php/ext/mcrypt does not exist
usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
if custom ./configure arguments are necessary, see docker-php-ext-configure
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql …
Run Code Online (Sandbox Code Playgroud) 那么伙计们,有很多不同的密码可供使用 - 但现在哪一个最安全?
尝试编写一些将加密或解密文件的函数,并使用此处的类来尝试实现此目的:
http://www.itnewb.com/v/PHP-Encryption-Decryption-Using-the-MCrypt-Library-libmcrypt
下面的加密函数似乎有效,因为它似乎加密文件并将其放在目标目录中.我现在正试图解密该文件,它只是死于"无法完成解密"的消息(在那里编码...)在php错误日志中没有任何内容,所以我不确定它为什么会失败,但由于mcrypt对我来说是全新的,我更倾向于相信我在这里做错了...
以下是功能:
//ENCRYPT FILE
function encryptFile() {
global $cryptastic;
$pass = PGPPASS;
$salt = PGPSALT;
$key = $cryptastic->pbkdf2($pass, $salt, 1000, 32) or die("Failed to generate secret key.");
if ($handle = opendir(PATH.'/ftpd')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$newfile = PATH.'/encrypted/'.$file.'.txt';
$msg = file_get_contents(PATH.'/ftpd/'.$file);
$encrypted = $cryptastic->encrypt($msg, $key) or die("Failed to complete encryption.");
$nfile = fopen($newfile, 'w');
fwrite($nfile, $encrypted);
fclose($nfile);
unlink(PATH.'/ftpd/'.$file);
}
}
closedir($handle);
}
//DECRYPT FILE
function …
Run Code Online (Sandbox Code Playgroud) 我使用下面常用的库进行加密.我想从Mcrypt将其升级到OpenSSL,以便我不再使用已弃用的库.
我试图找出这是否可能.我对此做了一些研究,但我发现了相互矛盾的信息:
这篇文章说,使用用Mcrypt加密的OpenSSL无法解密数据. /sf/answers/1382394611/
但是,这篇文章说可以使用填充.看来我的函数使用了填充.这是否是使这项工作所需的正确填充类型? /sf/answers/2213033931/
<?php
namespace Utilities\Encryption;
/**
* A class to handle secure encryption and decryption of arbitrary data
*
* Note that this is not just straight encryption. It also has a few other
* features in it to make the encrypted data far more secure. Note that any
* other implementations used to decrypt data will have to do the same exact
* operations.
*
* Security Benefits:
*
* - Uses Key stretching
* …
Run Code Online (Sandbox Code Playgroud) 目前我们在我们的系统上有一个mcrypt实现,用于在PHP应用程序中隐藏一些敏感数据.现在我们有了一个新的要求,我们必须将crypt模块更改为openssl.另一件重要的事情是我们使用密码河豚和模式ecb.所以我开始测试有什么区别以及如何使用openssl解密mcrypt加密字符串.
我使用标准的PHP函数:
两种方法都会产生不同的结果.第二件事是在两种类型的给定密码(河豚)和模式(ecb)中需要不同的IV长度(openssl = 0和mcrypt = 56).
有没有人知道如何在没有大量迁移工作的情况下轻松更改模块?
提前致谢!
更新:
这是代码,我测试了它:
<?php
function say($message){
if(!is_string($message)){
if(!isset($_SERVER["HTTP_USER_AGENT"])) echo "<pre>";
echo var_export($message, true) . ((!isset($_SERVER["HTTP_USER_AGENT"]) ? "\n" : "<br />"));
if(!isset($_SERVER["HTTP_USER_AGENT"])) echo "</pre>";
}else{
echo $message . ((!isset($_SERVER["HTTP_USER_AGENT"]) ? "\n" : "<br />"));
}
}
say("= Begin raw encryption");
$key = "anotherpass";
$str = "does it work";
say(" Params:");
say(" - String to encrypt '".$str."'");
say(" - Key: ".$key);
say("");
$params = array(
"openssl" => array(
"cipher" => "BF",
"mode" …
Run Code Online (Sandbox Code Playgroud) 我目前在解密由php mcrypt加密的邮件方面遇到了一些问题.php代码如下:
<?php
//$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$iv = "45287112549354892144548565456541";
$key = "anjueolkdiwpoida";
$text = "This is my encrypted message";
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv);
$crypttext = urlencode($crypttext);
$crypttext64=base64_encode($crypttext);
print($crypttext64) . "\n<br/>";
?>
Run Code Online (Sandbox Code Playgroud)
然后将加密的消息发送到ASP.NET平台(C#).但是,我在保留解密顺序(base64解码到urldecode)时遇到问题.我在ASP.NET中的代码如下(iv和key与php中的相同):
public string Decode(string str)
{
byte[] decbuff = Convert.FromBase64String(str);
return System.Text.Encoding.UTF8.GetString(decbuff);
}
static public String DecryptRJ256(string cypher, string KeyString, string IVString)
{
string sRet = "";
RijndaelManaged rj = new RijndaelManaged();
UTF8Encoding encoding = new UTF8Encoding();
try
{
//byte[] message = Convert.FromBase64String(cypher);
byte[] message …
Run Code Online (Sandbox Code Playgroud) 我正在使用PHP的mcrypt
库和 AES-256
(rijndael)算法,它需要运行密钥+初始化向量.
我的逻辑思维并不是真的与此同时存在.不只是一个关键吗?
理论场景:
如果我将加密的敏感数据存储在数据库中,只有所有者应该能够解密,那么将用户哈希密码用于他或她的数据的密钥或初始化向量是否合适?
密钥应该被认为比初始化向量更私密还是反过来?
我正在尝试使用128位AES加密(ECB)加密/解密字符串.我想知道的是如何添加/删除PKCS7填充.似乎Mcrypt扩展可以处理加密/解密,但必须手动添加/删除填充.
有任何想法吗?
mcrypt_decrypt():此算法不支持大小为15的密钥.仅支持尺寸为16,24或32的按键
我该如何解决这个问题?我的密钥已设置 - 无法更改它.它必须是本地更改,我认为我的本地PHP版本对于我加载的项目来说太先进了.我怎样才能解决这个问题?
最近我开始在我的应用程序中使用加密技术,我发现自己对输入文本长度和它产生的密文之间的关系感到困惑.在应用加密之前,很容易确定数据库列大小.但是,现在,列大小略有不同.
两个问题:
对于奖励积分:我应该在varchar中存储base64编码的密文,还是将其保存为原始字节并将其存储在varbinary中?将数据存储在我的数据库中是否存在风险(我使用参数化查询,因此理论上意外断开转义应该不是问题)?
TIA!
补充:我使用的密码是AES/Rijndael-256 - 这种关系在可用算法之间有所不同吗?
mcrypt ×10
php ×10
encryption ×6
cryptography ×2
openssl ×2
security ×2
aes ×1
c# ×1
decode ×1
docker ×1
dockerfile ×1
file ×1
pkcs#7 ×1