Home  >  Article  >  Backend Development  >  How to get the verification code image when logging in?

How to get the verification code image when logging in?

WBOY
WBOYOriginal
2016-12-05 13:44:161623browse

There will be a verification code when logging in. After looking at the code, its src points to a PHP address (maybe not a PHP address, so src="/login/verificationCode?0.8308222951445625"). When I open this address alone, garbled characters appear. , how can I cut out this picture? Prepare for the next step of identifying the verification code. Have you ever done any research on this? Thank you!

Reply content:

There will be a verification code when logging in. After looking at the code, its src points to a PHP address (maybe not a PHP address, so src="/login/verificationCode?0.8308222951445625"). When I open this address alone, garbled characters appear. , how can I cut out this picture? Prepare for the next step of identifying the verification code. Have you ever done any research on this? Thank you!

This is not garbled code, it is just a binary stream of jpg, gif, and png. Whether it is jpeg or png, you need to look at the first few characters of the binary stream. Last time, there were marks such as JPEG

Save this binary stream as 1.jpg and you can see the result

Or when requesting, set the content-type to image/jpeg so that the request should be visible directly

It is recommended that the questioner take a look at the TP verification code generation to understand the meaning of it

Verification code

I encountered the same problem

Just add a header to the http request to let the server know that it is a picture. The garbled code you are talking about is a binary stream. Copy it to .txt and save it as .jpg to open it and see it

Generally, verification code images are generated without storage or caching.
Revisiting the link will only generate a new image, so you need to store the image first and then call it.

In the previous project, we used js to call the interface and encrypted the binary stream resource of the verification code image to the client with base64_encode.
You can refer to the implementation method

Has the poster solved this problem? I'm encountering this problem too.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn