halalsoft / skip32
skip32 PHP实现 - 基于 Skipjack 的32位分组密码
0.1
2021-06-27 23:59 UTC
This package is auto-updated.
Last update: 2024-09-28 07:36:41 UTC
README
基于 Skipjack 的32位分组密码
此密码可用于混淆小型(32位)值,同时保持加密输出大小较小(也只有32位)。
skip32.php
使用 Skip32 密码进行加密/解密值的简单 API
示例
$key = '0123456789abcdef0123'; // 10 bytes key
$int = 4294967295; // 4 bytes integer
$encrypted = Skip32::encrypt($key, $int);
$decrypted = Skip32::decrypt($key, $encrypted);
printf("%d encrypted to %d\n", $int, $encrypted);
printf("%d decrypted to %d\n", $encrypted, $decrypted);
这将显示(在64位架构上)
4294967295 encrypted to 572455217
572455217 decrypted to 4294967295
Skip32Cipher.php
直接将 SKIP32 C 实现翻译成 Perl 的版本 http://search.cpan.org/~esh/Crypt-Skip32/lib/Crypt/Skip32.pm http://www.qualcomm.com.au/PublicationsDocs/skip32.c
示例
$key = pack('H20', '0123456789abcdef0123'); // 10 bytes key
$cipher = new Skip32Cipher($key);
$int = 4294967295; // 4 bytes integer
$bin = pack('N', $int);
$encrypted = $cipher->encrypt($bin);
list(, $encryptedInt) = unpack('N', $encrypted);
printf("%d encrypted to %d\n", $int, $encryptedInt);
$bin = pack('N', $encryptedInt);
$decrypted = $cipher->decrypt($bin);
list(, $decryptedInt) = unpack('N', $decrypted);
printf("%d decrypted to %d\n", $encryptedInt, $decryptedInt);
这将显示(在64位架构上)
4294967295 encrypted to 572455217
572455217 decrypted to 4294967295
由Nicolas Lenepveu完成 n.lenepveu@gmail.com