Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
XTEA block cipher implementation (PHP MCRYPT_XTEA compatible) with support for ECB and CBC modes of operation and PKCS7 padding.
A pure JavaScript implementation of XTEA block cipher with support for ECB and CBC modes of operation.
The PKCS#7 padding is used for processing data not alligned to 8-byte block size.
The XTEA cipher algorithm is very effective and is supported by PHP's mcrypt cryptographic extension (in contrast to XXTEA cipher) so you may find this module useful when you need interoperability between JS and PHP and don't need stronger cryptography.
This module exports four functions:
Encrypts data using XTEA cipher using specified block cipher mode of operation and PKCS#7 padding.
Decrypts data using XTEA cipher using specified block cipher mode of operation and PKCS#7 padding.
Encrypts single block of data using XTEA cipher.
Decrypts single block of data using XTEA cipher.
var xtea = require('xtea');
var plaintext = new Buffer('Zażółć gęślą jaźń', 'utf8');
var key = new Buffer('33fd7bd6d85ddbe134c23fcb09c37e5a', 'hex');
var ciphertext = xtea.encrypt( plaintext, key );
console.log( ciphertext.toString('hex') );
console.log( xtea.decrypt( ciphertext, key ).toString() );
expected output:
da9466824a7606cf8faa4bf462c667c1dc4a23cb508199fdd6689b5134640e09
Zażółć gęślą jaźń
function xtea_encrypt($msg, $key, $mode, $iv) {
$pad = 8 - (strlen($msg) % 8);
$msg .= str_repeat(chr($pad), $pad);
return mcrypt_encrypt(MCRYPT_XTEA, $key, $msg, $mode, $iv);
}
function xtea_decrypt($msg, $key, $mode, $iv) {
$msg = mcrypt_decrypt(MCRYPT_XTEA, $key, $msg, $mode, $iv);
$pad = ord($msg[ strlen($msg) - 1 ]);
return substr($msg, 0, strlen($msg) - $pad);
}
Install dev dependencies and execute npm run test
:
$ npm install -d
$ npm run test
\newpage
The MIT License (MIT)
Copyright (c) 2015 Sebastian Smyczynski, Simplito Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
XTEA block cipher implementation (PHP MCRYPT_XTEA compatible) with support for ECB and CBC modes of operation and PKCS7 padding.
The npm package xtea receives a total of 751 weekly downloads. As such, xtea popularity was classified as not popular.
We found that xtea demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.