blowfish

Blowfish encryption in php

纵然是瞬间 提交于 2019-12-06 07:58:36
I'm writing an encryption to my application and website, but I don't know how to correctly encrypt the string in php. Decryption is already done by this code: function decrypt_blowfish($data,$key){ $iv=pack("H*" , substr($data,0,16)); $key=pack("H*" , $key); $x =pack("H*" , substr($data,16)); $res = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $x , MCRYPT_MODE_CBC, $iv); return $res; } I tried with simple: function encrypt_blowfish($data,$key){ $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $crypttext = mcrypt_encrypt(MCRYPT_BLOWFISH,

Java - Missing final characters when encrypting using blowfish

拈花ヽ惹草 提交于 2019-12-06 03:07:09
问题 I am using some java code that encrypts the contents of a text file using Blowfish. When I convert the encrypted file back (i.e. decrypt it) the string is missing a character from the end. Any ideas why? I am very new to Java and have been fiddling with this for hours with no luck. The file war_and_peace.txt just contains the string "This is some text". decrypted.txt contains "This is some tex" (with no t on the end). Here is the java code: public static void encrypt(String key, InputStream

Encrypt in C# and decrypt in Flex

橙三吉。 提交于 2019-12-05 23:15:14
I need to decrypt some data in Flex that is encrypted in C# and written to a file. I settled on blowfish for simplicity's sake using the as3crypto As3 library and Bruce Schneier C# library. AS3 as3crypto link Bruce Schneier C# blowfish link I can get a short string to encrypt in C# and decrypt in Flex fine however longer strings just fail to produce results and I do not know what I am missing? C#: string reportstring = "watson?"; BlowFish b = new BlowFish("04B915BA43FEB5B6"); string cipherText = b.Encrypt_ECB(reportstring); String plainText = b.Decrypt_ECB(cipherText); AS3: var txt:String =

Decrypting mcrypt encoded text with node.js

被刻印的时光 ゝ 提交于 2019-12-05 12:27:09
I have text encoded with Blowfish using PHP's mcrypt: $td = mcrypt_module_open ('blowfish', '', 'cfb', ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, "somekey", $iv); $crypttext = mcrypt_generic ($td, "sometext"); mcrypt_generic_deinit ($td); $res = base64_encode($iv.$crypttext); When trying to decode the data with Node's crypto library I get garbage output. var crypto = require("crypto"), ivAndCiphertext = "base64-encoded-ciphertext", iv, cipherText, ivSize = 8, res= ""; ivAndCiphertext = new Buffer(ivAndCiphertext, 'base64'); iv = new

Is Bcrypt used for Hashing or Encryption? A bit of confusion

◇◆丶佛笑我妖孽 提交于 2019-12-04 22:33:40
I have been reading about bcrypt (application perspective). Thinking of using it to store passwords on my site. Out of some stuff that I read it suggests either ways: e.g. 1: Bcrypt is a cross platform file encryption utility from bcrypt e.g. 2: bcrypt is an adaptive password hashing algorithm which uses the Blowfish keying schedule, not a symmetric encryption algorithm. from How To Safely Store A Password bcrypt is an adaptive cryptographic hash function for passwords designed by Niels Provos and David Mazières, based on the Blowfish cipher: from bcrypt wiki What exactly is Bcrypt? It is both

PHP storing password with blowfish & salt & pepper

本秂侑毒 提交于 2019-12-04 19:02:52
I want to store secure user passwords in a MySQL database with PHP. How can I make it better? My Class: private static $algo = '$2a'; private static $cost = '$10'; private static $pepper = 'eMI8MHpEByw/M4c9o7sN3d'; public static function generateSalt($length) { $randomBinaryString = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); $randomEncodedString = str_replace('+', '.', base64_encode($randomBinaryString)); return substr($randomEncodedString, 0, $length); } public static function generateHash($password) { if (!defined('CRYPT_BLOWFISH')) die('The CRYPT_BLOWFISH algorithm is required (PHP 5.3)

Encrypting a string with Blowfish in ruby returns a shorter string than the same process in php

橙三吉。 提交于 2019-12-04 12:16:48
This is confusing me. When I try and use the following inputs to encrypt a string with Blowfish: key = "some key" input = "input string" I get the following results: ruby: ["79af8c8ee9220bde"] php: 79af8c8ee9220bdec2d1c9cfca7b13c6 I am going to be receiving strings from a php application so I need to get these two to sync up but I don't understand why the php string would be longer. What am I missing? php code: php > require_once 'Crypt/Blowfish.php'; php > $input = "input string"; php > $key = "some key"; php > $crypt = new Crypt_Blowfish($key); php > echo bin2hex($crypt->encrypt($input));

Changing password with CakePHP and blowfish

倾然丶 夕夏残阳落幕 提交于 2019-12-04 11:18:46
I'm trying to set up a form to allow a user to change their password using CakePHP 2.3. The algorithm being used is blowfish. I have the following three fields: <?php echo $this->Form->input('old_password', array('type' => 'password', 'autocomplete' => 'off')); ?> <?php echo $this->Form->input('new_password', array('type' => 'password', 'autocomplete' => 'off')); ?> <?php echo $this->Form->input('new_password_confirm', array('type' => 'password', 'autocomplete' => 'off', 'label' => 'Confirm Password')); ?> Here is the code where I'm trying to verify they entered their old password correctly:

Java - Missing final characters when encrypting using blowfish

拥有回忆 提交于 2019-12-04 10:04:05
I am using some java code that encrypts the contents of a text file using Blowfish. When I convert the encrypted file back (i.e. decrypt it) the string is missing a character from the end. Any ideas why? I am very new to Java and have been fiddling with this for hours with no luck. The file war_and_peace.txt just contains the string "This is some text". decrypted.txt contains "This is some tex" (with no t on the end). Here is the java code: public static void encrypt(String key, InputStream is, OutputStream os) throws Throwable { encryptOrDecrypt(key, Cipher.ENCRYPT_MODE, is, os); } public

Moving from mcrypt with Blowfish & ECB to OpenSSL

半腔热情 提交于 2019-12-04 03:25:29
问题 In the (not too distant) past a decision has been made (by someone who longer works here) to always 'encrypt' database IDs to something else, on the fly, whenever it was needed for external communication. Now, we've moved from PHP 5.x to PHP 7.0 for our main application, and our microservices scattered across our infrastructure are running either 7.0 or 7.1. The 7.1 servers keep throwing deprecation warnings for the mcrypt stuff. No biggie, just yet. But with PHP 7.2 around the corner, we