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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:19:25+00:00 2026-06-15T16:19:25+00:00

Problem with base64 $data = ‘my data’; echo $encryptedData = base64_encode($data); // Output :

  • 0

Problem with base64

$data = 'my data';
echo $encryptedData = base64_encode($data);

// Output :
bXkgZGF0YQ==

I added some more characters to the token

$encryptedData = $encryptedData . 'sdfsdfasdfsd';
echo $data = base64_decode($encryptedData);

// Output :
my data~Ç_jÇ_±

Now i got actual data + junk data. i dont want any of the data or only the data if there is any change in the token. is there any method to implement this ?

  • 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-15T16:19:26+00:00Added an answer on June 15, 2026 at 4:19 pm

    To make sure changes to the base64 encoded string can only be made by changing the $data, you will need to add a verification token.

    An easy way to add such verification is by using a keyed hash whereby the key is secret:

    $data = 'this product sells for 5 dollars';
    $enc = base64_encode($data);
    $token = base64_encode(hash_hmac('sha256', $enc, 'your secret key here', true));
    
    $my_token = $token . ':' . $enc;
    

    Output:

    ZMkqZIa6UazMhbYDiPqjdS1NmU1ulh+Gi2tgWHRKKpQ=:dGhpcyBwcm9kdWN0IHNlbGxzIGZvciA1IGRvbGxhcnM=
    

    When you receive such token, you first split on : and then use the first part (keyed hash) to verify the contents of the second part (data). Only if it matches, you can be (relatively) sure that the data has not been tampered with.

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

Sidebar

Related Questions

I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I need to encode some data in the Base64 encoding in Java. How do
I have the problem that I am trying to send data as a base64
I have some problem for decoding image data from base 64 encoded string. I
I have a problem for encoding my data to base64 in php. I want
Problem: I am trying to build a recursive tree using a function and data
I am writing a StringOutputStream class in Java because I need the pre-Base64-encoded data
Is it possible to use a RegEx to validate, or sanitize Base64 data? That's
I'm trying to do a mock-up in Matlab on some image data in a
I receive some xml-files with embedded base64-encoded images, that I need to decode and

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.