php - 如何在 PHP 中制作个人哈希算法

标签 php algorithm hash crypt

我想在 PHP 中制作一个散列文本的个人算法。 'xyz'中的字母'a'地穴,'256'中的'b'等等。这怎么可能?

最佳答案

可以通过简单地创建一个函数来进行字符替换,如下所示:

function myEncrypt ($text)
{
    $text = str_replace(array('a', 'b'), array('xby', '256'), $text);
    // ... others

    return $text;
}

带有两个数组“search”和“replaceWith”作为参数传递的版本:

function myEncrypt ($text, $search=array(), $replaceWith=array())
{
    return str_replace($search, $replaceWith, $text);   
}

WARNING: That way isn't a correct solution to encrypt a text, there are a lot of better ways to do a secure encryption with PHP (see for example this post).

关于php - 如何在 PHP 中制作个人哈希算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48337821/

相关文章:

perl - 为什么我收到 "Odd number of elements in anonymous hash "警告

arrays - 在 Perl 中循环遍历数组的哈希值

php - 如何在背景图像的一部分中设置图像映射?

django - Django 中的应用程序设计

javascript - javascript中的小迭代

java - 将 128 位数组优化打包成一个数字

arrays - 如果在数组中找不到,perl 删除散列项

php - 如何在查询中使用保留关键字

php - 如何检索 Google+ oAuth2 个人资料缩略图

php - 我如何修复此查询以仅返回其子数组中具有特定值的项目?