Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8404391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:35:18+00:00 2026-06-09T22:35:18+00:00

I want to encrypt a message in php with a known password using blowfish.

  • 0

I want to encrypt a message in php with a known password using blowfish. I would then be like to decrypt this message in python.

This is useful even if you want to encrypt in one language and decrypt elsewhere.

I searched quite extensively but could not find any conclusive solution, so I thought to record my findings.

Note it is quite simple to encrypt/decrypt in same language such as python or php.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:35:19+00:00Added an answer on June 9, 2026 at 10:35 pm

    This solution is very simple but it took me a while to figure out.

    Blowfish Params

    • Password should be of length 16
    • use mode MODE_ECB.
    • Data being encrypted length should be always divisible by 16 pad by spaces or anyother char. I have taken a 16 length data string in example below.

    php code:

    <?php
    $passw='secretPassword12';
    $ntext='helloWorld123456';
    $enc = base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $passw, $ntext, MCRYPT_MODE_ECB));
    echo '<div>'.$enc.'</div';
    

    This outputs 3C8f2kaD8Of0INYk3l9qEg==
    python code:

    from Crypto.Cipher import Blowfish
    from base64 import b64encode, b64decode
    passw='secretPassword12'
    ntext='helloworld123456'
    
    cipher=Blowfish.new(passw, Blowfish.MODE_ECB)
    encStr=b64encode(cipher.encrypt(data))
    print encStr
    

    This code outputs 3C8f2kaD8Of0INYk3l9qEg== too

    Now suppose you want to decrypt some string in python encrypted in php. First do b64decode and then decrypt the result.

    Remember to pad your data such that the len is divisible by 16. 
    

    Happy encrypting and decrypting!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to encrypt a message such as 'HELO1234 and then decrypt to get
I'm struggeling with code from this page: http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php I want to send data from
If I want to sign and encrypt a message using an X509 certificate, is
I want to encrypt some server data using .NET's RSACryptoServiceProvider and decrypt it when
I want to encrypt a message by php but at client side, I want
I want to encrypt a image and then decrypt it. Is there any good
i want to encrypt string in java and decrypt the same string in C#
This is a basic security app and i just want to encrypt & decry-pt
I want my application to encrypt a user password, and at one time password
I want to encrypt the communication between a LabView and a Python code. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.