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

  • SEARCH
  • Home
  • 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 971943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:02:40+00:00 2026-05-16T03:02:40+00:00

I am migrating my PHP code to Google App Engine – Java. So I

  • 0

I am migrating my PHP code to Google App Engine – Java.
So I need an equivalent of PHP’s crypt function in Java,
since I have stored all the passwords of registered users
using crypt in my DB.

Edit 1:
Here is my php code for encrypting passwords :

$password = “test123”;
$pwd = crypt($password,$password);
echo $pwd;

Output is (On Windows as well as a linux based server on HostMonser):
temjCCsjBECmU

Can someone give me equivalted java code?
I have tried various permutations & combinations with
MessageDigest class, but can’t get it right..

Edit 2:
Here is sample code which I thought would work but did not:

try {
                {
                    String password = "test123";
                    MessageDigest digest = MessageDigest.getInstance( "MD5" ); 
                    byte[] passwordBytes = password.getBytes( ); 

                    digest.reset( );
                    digest.update( passwordBytes );
                    digest.update( passwordBytes );
                    byte[] message = digest.digest( );

                    StringBuffer hexString = new StringBuffer();
                    for ( int i=0; i < message.length; i++) 
                    {
                        hexString.append( Integer.toHexString(
                            0xFF & message[ i ] ) );
                    }
                    String encrypted = hexString.toString();
                    System.out.println(encrypted);
                  } } catch (NoSuchAlgorithmException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
  • 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-05-16T03:02:41+00:00Added an answer on May 16, 2026 at 3:02 am

    You have to know what implementation of PHP crypt has been used (MD5? SHA256? SHA512?) because there are several, depending on your OS : http://php.net/manual/fr/function.crypt.php

    The Java equivalent class is MessageDigest. When you create an instance of this class, you provide the hash algorithm, for example :

    MessageDigest md = MessageDigest.getInstance("MD5");
    MessageDigest md2 = MessageDigest.getInstance("SHA-256");
    MessageDigest md3 = MessageDigest.getInstance("SHA-512");
    // etc.
    byte[] encryptedPassword = md.digest("yourPassword".getBytes());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am migrating my PHP code to Google App Engine - Java. Since I
I am migrating my PHP code to Ruby and at some point I need
Migrating app from php. and have this in the view: <%=render :partial => jt-test,
I've just come to Python from PHP after inheriting a legacy google app engine
Newbie question about PostgreSQL. I'm migrating a MySQL/PHP app I've created, hosted on a
date = re.search(r'([\x\d\w-.\s,()&\]+|) I am migrating a code from PHP to Python, and am
Migrating from PHP to EJB , I have previous experience of PHP , C++
I'm migrating a old (circa 2001) PHP 3 app to a new PHP5 server.
I'm migrating from server side development (java, php) to client side - HTML, CSS,
I have these two file in my project that I am migrating from php.

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.