foxworn3365/prohash

该软件包最新版本(dev-main)没有可用的许可证信息。

ProHash是一个用于使用自动生成的密钥加密和解密字符串的系统。没有它,几乎无法解密内容

dev-main 2023-02-18 09:47 UTC

This package is auto-updated.

Last update: 2024-09-18 13:30:06 UTC


README

ProHash是一个用于使用自动生成的密钥加密和解密字符串的系统。没有它,几乎无法解密内容

安装

您可以使用composer安装

composer require foxworn3365/prohash

或者您可以下载名为prohash.php的文件并将其包含进来

require_once('prohash.php');

如何使用ProHash

ProHash是如何工作的

ProHash生成的字符串是完全随机生成的,但也为您提供了解密的密钥。
唯一可以提供此密钥的函数是Class->new(<STRING>)

无密钥的哈希 - 新密钥

Class->new(<STRING>);

将返回一个array

{
   [string] => <ENCODED STRING>,
   [key] => <FULL KEY FOR ENCRYPT/DECRYPT>
}

带密钥的哈希

Class->encode(<STRING>, <KEY>);

将返回一个包含哈希内容的string

使用密钥解密

Class->decode(<STRING>, <KEY>);

将返回一个包含普通内容的string

示例

<?php
require 'prohash.php';
use Fox\Hash as Hash;

$hash = new Hash();

// Now let's go encrypt the string
$result = $hash->new('my name is Paolo Bonolis');

// The key is in $result["key"] and the encrypted string is in $result["string"];

// Now let's go decrypt the string
$myString = $hash->decrypt($result["string"], $result["key"]); // OUTPUT: my name is Paolo Bonolis

// Now we can also encrypt a string with an existent key
$temp = $hash->encrypt('my name is Federico', $result["key"]); // THE OUTPUT WILL BE EQUAL TO $result["string"];