dbeurive/cast128

此项目实现了 RFC 2144 - CAST-128 加密算法。

1.0.0 2018-09-19 12:23 UTC

This package is not auto-updated.

Last update: 2024-09-13 16:59:31 UTC


README

此存储库包含一个PHP模块,该模块实现了根据RFC 2144指定的CAST-128加密算法。

安装

从命令行

composer require dbeurive\cast128

如果您想将此包包含到项目中,请编辑您的 composer.json 文件并添加以下条目

"require": {
    "dbeurive/cast128": "*"
}

概要

use dbeurive\Cast128\Cast128;

$key = array(0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 0x23, 0x45);
$data_to_cypher = array(0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF); // 32-bit long!
$cypher = new Cast128($key);
$cyphered = $cypher->cypher($data_to_cypher);
$deciphered = $cypher->decipher($cyphered);

密钥:密钥由一个8位整数数组表示(从0到255)。数组包含5到16个值。也就是说,密钥的长度从40位到128位不等。

要加密/解密的密文:这些数据由一个正好包含8个值的数组表示。也就是说,要加密的数据是一个32位的值。