0

I unforesee the result.

This is my encryption method:

const METHOD = "AES-256-ECB";
public $key;

public function encrypt($string,$key){
        return strtr(base64_encode(openssl_encrypt($string, $this::METHOD, hash('sha256', $key, true))), '+/=', '-_,');
}

This code generates the $key for encryption.

$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        $max = strlen($string) - 1;
        $token = '';
        for ($i = 0; $i < 32; $i++) {
            $token .= $string[mt_rand(0, $max)];
        }
        $key = $token;

My question is: ? & these signs can the result in?

because I am using the $_GET parameters in.

7
  • I can not get the idea of the question ? can you please paste a functional code? Commented Oct 11, 2018 at 11:18
  • I want to say simply this. $result = strtr(base64_encode(openssl_encrypt("HELLOWORD", "AES-256-ECB", hash('sha256', rand(1000,9999), true))), '+/=', '-_,'); This $result may contain these signs "? &". Commented Oct 11, 2018 at 11:30
  • My english not well. Maybe i cant say what i want to say sorry, but looking understandable. :D Commented Oct 11, 2018 at 11:33
  • 3
    It shouldn't matter because you should be URL Encoding any raw data that you are inserting into a query string anyway. Commented Oct 11, 2018 at 11:40
  • 1
    It's not the point here, but this code isn't secure. The ECB is not safe, you can see the encrypted penguin, also anyone can modify the encrypted text. The mt_rand is not cryptographically secure, also there's no reason to forces the key to be alphanumeric-only. Commented Oct 11, 2018 at 12:26

1 Answer 1

1

No, any output of base64 encode are chars from 0 to 63 only + and / are the non letters or numbers

take a look in https://en.wikipedia.org/wiki/Base64#Base64_table

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.