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 8314013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:40:57+00:00 2026-06-08T20:40:57+00:00

I have to update one web app from Java to PHP and I found

  • 0

I have to update one web app from Java to PHP and I found some hard problems…
The big problem is to convert the SHA1 from Java to PHP because someone before me developed an browser extension that need a particular auth code to work… i can’t change the plugin, i have only to convert the web app from java to php…

This is the code:

 private static final byte[] SecretKey;

  public static String AuthCode(String url) {

    byte[] urlBytes = url.getBytes("US-ASCII");

    byte[] concatenated = new byte[SecretKey.length + urlBytes.length];
    System.arraycopy(SecretKey, 0, concatenated, 0, SecretKey.length);
    System.arraycopy(urlBytes, 0, concatenated, SecretKey.length, urlBytes.length);

    byte[] hash = HashTools.calculateHash(concatenated, "SHA1");
    return CodecTools.encodeBASE64(hash);
  }

  static {
    SecretKey = new byte[] { 18, -15, -48, 73, 54, -115, 34, -87 };
  }

Now, I found very hard convert the SecretKey from byte to something else in php.. because php don’t have byte variable… and i read that sha1 in php is different from java.

In PHP I can’t make a sha1 of a array chars, it want only a String…

(the other stackoverflow answers suggest only how to change Java code to be equal to php.. I need that the PHP code should be equal to Java…)

I hope in someone that help me because I don’t really know Java…

Thanks to all 🙂

  • 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-08T20:40:58+00:00Added an answer on June 8, 2026 at 8:40 pm

    Use a simple string as byte container.

    for example, if you want to store the secret key:

    $secretKeyArray = array(18, -15, -48, 73, 54, -115, 34, -87);
    
    $secretString = '';
    foreach($secretKeyArray as $k => $v) {
       $secretString.= chr($v & 0xFF); // trim to 8 bits (for the negative values)
    }
    

    Now you have the secret key stored in $secretString.

    Edit:

    the concatenated array would be:

    $concatenated = $secretString . $url;
    

    and then

    return base64_encode(sha1($concatenated, true));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've creating one ASP web application, in that application one form have to update
I have a web app that works fine from all browsers (IE9, Firefox, Chrome,
I have a Java web application which stores some data in the session. The
I have one place in a web app where I'm doing a lot of
I have to update one element on page with Ajax, do I have to
I have 2 update panel in one update panel i have a datalist and
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have one demo application to check select for update query public class Test
I have one user (only one, all the others are fine) trying to update
I have one table TABLE_EXAM . i need to update the value of specific

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.