Method, system, terminal and storage medium for generating a WhatsApp key based on OCR recognition
Patent Information
- Application Number
- CN202211542174.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-02
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2042-12-02
AI Technical Summary
[0006]本发明的主要目的是提供一种基于OCR识别生成WhatsApp密钥的方法,旨在解决现有的解密需要用户手动输入密钥的问题
[0038]Beneficial Effects: This invention provides a method, system, terminal, and storage medium for generating WhatsApp keys based on OCR recognition. The method includes: acquiring a WhatsApp key image; extracting a key area image from the key image using background color differentiation; recognizing the key area image using OCR to output a key string; and importing the key string into a local file to obtain a key file. This invention simplifies the user's interaction when inputting keys, directly generating a key file from the key area image without requiring manual key input, thus improving input accuracy, increasing decryption success rate, and enhancing user experience.
Smart Images

Figure CN115952488B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of identification key technology, specifically to a method, system, terminal, and storage medium for generating WhatsApp keys based on OCR identification. Background Technology
[0002] WhatsApp is one of the most popular instant messaging apps abroad, partly because users' chat history is not saved on the WhatsApp device but only on their phones. This is very user-friendly for users abroad who value privacy and data security. When users need to back up their chat data, WhatsApp writes all chat messages to an SQLite database, then compresses and encrypts the database, generating a crypt file in the phone's cache directory.
[0003] With the continuous iteration of WhatsApp's backup encryption function, the latest version is Crypto15 encryption. Crypto15 encryption includes a key encryption method. This method, when encrypting WhatsApp backups, sends a screenshot of the key in hexadecimal format to the user, allowing the user to save the key as an image. Figure 5 As shown.
[0004] Where there is encryption, there is decryption. Since the key is saved as an image, when it is necessary to read the key content and generate a key file that can be decrypted, the user needs to manually enter hexadecimal numbers.
[0005] Its decryption method has the following drawbacks: 1. Manually entering the key incurs a very high interaction cost for the user; 2. Entering 64 hexadecimal numbers is prone to errors, leading to decryption failure. Summary of the Invention
[0006] The main objective of this invention is to provide a method for generating WhatsApp keys based on OCR recognition, aiming to solve the problem that existing decryption methods require users to manually enter the key.
[0007] The first aspect of this invention provides a method for generating WhatsApp keys based on OCR recognition, comprising the following steps:
[0008] Get the WhatsApp key image;
[0009] The key area image is captured by distinguishing it by background color in the key image;
[0010] The key region image is identified using OCR, and a key string is output.
[0011] Import the key string into a local file to obtain a key file.
[0012] In an optional embodiment of the first aspect of the present invention, the step of extracting a key region image from the key image by means of background color differentiation includes the following steps:
[0013] Obtain all pixel values from the key image and store them in the first array;
[0014] Iterate through the pixel values in the first array, find the pixel values in the first array that are the same as the background color pixel values of the key area, mark the first matching pixel value as the first pixel value, and mark the last matching pixel value as the second pixel value;
[0015] In the first array, all pixel values between the first pixel value and the second pixel value are extracted and output as the second array;
[0016] Regenerate the image using all pixel values in the second array, and output the result as a key region image.
[0017] In an optional embodiment of the first aspect of the present invention, before the key string is imported into a local file after the key region image is identified by OCR and the key string is output, the method further includes the following steps:
[0018] Traverse the key string and correct and replace specific characters in the key string according to the preset character replacement table.
[0019] In an optional embodiment of the first aspect of the present invention, before the key string is imported into a local file after the key region image is identified by OCR and the key string is output, the method further includes the following steps:
[0020] Determine if the system language is Arabic;
[0021] If so, reverse the characters in the key string and then re-output the reversed key string;
[0022] If not, output the original key string.
[0023] In an optional embodiment of the first aspect of the present invention, importing the key string into a local file to obtain a key file includes the following steps:
[0024] Create a byte array;
[0025] Iterate through the key string, adding each preset number of digits in the key string as one byte to the byte array;
[0026] Import the added byte array into a local file using a file output stream to obtain the key file.
[0027] In an optional embodiment of the first aspect of the present invention, the key image includes a key region and other regions, the key region including key characters; wherein the background color of the key region is different from the background color of the other regions.
[0028] In an optional embodiment of the first aspect of the present invention, the step of recognizing the key region image by OCR and outputting the key string includes the following steps:
[0029] The key area image is transmitted to the OCR system via the OCR interface;
[0030] The text recognition system in the OCR identifies the text portion within the key area image and outputs the text portion as a key string in text format.
[0031] A second aspect of the present invention provides a system for generating WhatsApp keys based on OCR recognition, comprising:
[0032] The module is used to retrieve the WhatsApp key image;
[0033] The capture module is used to capture the key area image from the key image by distinguishing it by background color;
[0034] The recognition module is used to recognize the key area image through OCR and output the key string;
[0035] The import module is used to import the key string into a local file to obtain a key file.
[0036] A third aspect of the present invention provides a terminal for generating a WhatsApp key based on OCR recognition, the terminal comprising: a memory and at least one processor, the memory storing instructions, the memory and the at least one processor being interconnected via a line; the at least one processor calling the instructions in the memory to cause the terminal to execute the method for generating a WhatsApp key based on OCR recognition as described in any of the preceding claims.
[0037] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, characterized in that a processor is configured to execute the computer program stored in the storage medium to implement the method for generating a WhatsApp key based on OCR recognition as described in any of the preceding claims.
[0038] Beneficial Effects: This invention provides a method, system, terminal, and storage medium for generating WhatsApp keys based on OCR recognition. The method includes: acquiring a WhatsApp key image; extracting a key area image from the key image using background color differentiation; recognizing the key area image using OCR to output a key string; and importing the key string into a local file to obtain a key file. This invention simplifies the user's interaction when inputting keys, directly generating a key file from the key area image without requiring manual key input, thus improving input accuracy, increasing decryption success rate, and enhancing user experience. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0040] Figure 1 This is a flowchart of an embodiment of a method for generating WhatsApp keys based on OCR recognition according to the present invention;
[0041] Figure 2 for Figure 1 A flowchart of one embodiment of step S200;
[0042] Figure 3 This is a screenshot of the WhatsApp key used in this invention;
[0043] Figure 4 This is a schematic diagram of a system for generating WhatsApp keys based on OCR recognition according to the present invention;
[0044] Figure 5 This is a schematic diagram of an embodiment of a terminal according to the present invention.
[0045] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0046] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0047] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.
[0048] Furthermore, in this invention, descriptions involving "first," "second," etc., are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0049] In this invention, unless otherwise explicitly specified and limited, the terms "connection," "fixed," etc., should be interpreted broadly. For example, "fixed" can mean a fixed connection, a detachable connection, or an integral part; it can mean a mechanical connection or an electrical connection; it can mean a direct connection or an indirect connection through an intermediate medium; it can mean the internal communication of two components or the interaction between two components, unless otherwise explicitly limited. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0050] Furthermore, the technical solutions of the various embodiments of the present invention can be combined with each other, but only if they are feasible for those skilled in the art. If the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.
[0051] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1 The first aspect of this invention provides a method for generating a WhatsApp key based on OCR recognition. This method is implemented in software and includes the following steps:
[0052] S100, Obtain the WhatsApp key image;
[0053] Users open the corresponding software, find the relevant WhatsApp key image from their photo album or other links, and select the key image.
[0054] S200: In the key image, the key area image is captured by distinguishing it by background color;
[0055] Because the existing WhatsApp key image templates are all the same, such as Figure 3 The image shown is a WhatsApp key image. The gray background area is the key area. In the actual image, the background color of this key area is light green, while all other areas have a white background. All numbers, letters, and text in the key image are in black font. The key area contains 64 hexadecimal digits, specifically the numbers 0-9, and the lowercase letters 'af'. These 64 hexadecimal digits are divided into four rows, each containing four bytes, with each byte containing four hexadecimal digits. The purpose of cropping the key area image is to ensure that subsequent OCR only recognizes the numbers and letters within the key area, preventing the OCR from recognizing text from other areas and causing garbled characters.
[0056] S300: Recognize the key region image using OCR and output the key string;
[0057] OCR recognizes the key area image, extracts the numbers and letters within the key area image, and outputs a key string in text format.
[0058] S400. Import the key string into a local file to obtain a key file.
[0059] Please see Figure 2 In an optional embodiment of the first aspect of the present invention, the step of extracting the key region image from the key image by means of background color differentiation includes the following steps:
[0060] S201. Obtain all pixel values in the key image and store them in the first array;
[0061] The key image is composed of multiple pixels, each pixel corresponding to a pixel value (RGB value). The pixel value of the light green background color of the key area is -983046. In step S201, firstly, the pixel value corresponding to each pixel in the key image is obtained, and then the pixel value corresponding to each pixel is stored in the first array according to the order of each pixel in the key image.
[0062] S202. Traverse the pixel values in the first array, find the pixel values in the first array that are the same as the background color pixel values of the key area, mark the first same pixel value as the first pixel value, and mark the last same pixel value as the second pixel value.
[0063] Since the background color of the key area is light green, and its corresponding pixel value is -983046, in step S202, we need to find the first -983046 value in the first array. The pixel corresponding to the first -983046 value is the pixel located at the top left corner of the key area. We also need to find the last -983046 value. The pixel corresponding to the last -983046 value is the pixel located at the bottom right corner of the key area.
[0064] S203. In the first array, extract all pixel values between the first pixel value and the second pixel value, and output them as the second array;
[0065] Extract all pixel values between the first pixel value and the second pixel value. The extracted pixel values include the pixel values corresponding to all pixels in the entire key area, specifically including the pixel values corresponding to the light green background color in the key area, and the pixel values corresponding to the black numbers and letters in the key area.
[0066] S204. Regenerate the image from all pixel values in the second array and output it as a key region image.
[0067] Step S204 involves regenerating the image from the pixel values extracted in step S203.
[0068] In an optional embodiment of the first aspect of the present invention, before the key string is imported into a local file after the key region image is identified by OCR and the key string is output, the method further includes the following steps:
[0069] Traverse the key string and correct and replace specific characters in the key string according to the preset character replacement table.
[0070] The preset character replacement table includes, but is not limited to: replacing o and O (uppercase and lowercase O) with 0 (number 0), z and Z (uppercase and lowercase Z) with 2, q with 9, and g and B with 8. In the step of recognizing the key area image using OCR and outputting the key string, OCR may encounter recognition errors; for example, recognizing 0 as o or O (uppercase and lowercase O), 2 as z or Z (uppercase and lowercase Z), 9 as q, and 8 as g or B. In this case, the incorrectly recognized characters need to be corrected and replaced. It is important to note that since the key characters are 64-bit hexadecimal numbers, specifically the numbers 0-9 and the lowercase letter af, if the OCR recognizes the key area image and outputs a key string containing o and O (uppercase and lowercase O), z and Z (uppercase and lowercase Z), q, g, and B, the reason is likely a recognition error in the OCR recognition of the key area image. Therefore, we only need to correct the incorrectly recognized numbers and letters.
[0071] In an optional embodiment of the first aspect of the present invention, before the key string is imported into a local file after the key region image is identified by OCR and the key string is output, the method further includes the following steps:
[0072] Determine if the system language is Arabic. If so, reverse the characters in the key string and then re-output the reversed key string. If not, output the original key string.
[0073] In this embodiment, since Arabic is read from right to left, the characters in the key string are reversed if the text is Arabic. It should be noted that because the key string is divided into four rows, each row is reversed separately when reversing the characters.
[0074] In an optional embodiment of the first aspect of the present invention, importing the key string into a local file to obtain a key file includes the following steps:
[0075] Create a byte array;
[0076] In practical applications, a byte array can be a byte array of length 32.
[0077] Iterate through the key string, adding each preset number of digits in the key string as one byte to the byte array;
[0078] In practical applications, each pair of hexadecimal numbers in the key string can be added as one byte to a byte array of length 32.
[0079] Import the added byte array into a local file using a file output stream to obtain the key file.
[0080] In an optional embodiment of the first aspect of the present invention, the key image includes a key region and other regions, the key region including key characters; wherein the background color of the key region is different from the background color of the other regions.
[0081] In an optional embodiment of the first aspect of the present invention, the step of recognizing the key region image by OCR and outputting the key string includes the following steps:
[0082] The key area image is transmitted to the OCR system via the OCR interface;
[0083] The text recognition system in the OCR identifies the text portion within the key area image and outputs the text portion as a key string in text format.
[0084] In this embodiment, the purpose is to use OCR to recognize the text portion within the key area image and output the recognized text portion to a text format, where the string in the text format is the key string corresponding to the key image.
[0085] See Figure 4 A second aspect of the present invention provides a system for generating WhatsApp keys based on OCR recognition, comprising:
[0086] Module 10 is used to obtain the WhatsApp key image;
[0087] The capture module 20 is used to capture the key area image from the key image by distinguishing it by background color;
[0088] The recognition module 30 is used to recognize the key area image through OCR and output the key string;
[0089] Import module 40 is used to import the key string into a local file to obtain a key file.
[0090] In an optional embodiment of the second aspect of the present invention, the interception module 20 includes:
[0091] A pixel value acquisition unit is used to acquire all pixel values in the key image and store them in the first array;
[0092] The pixel value marking unit is used to traverse the pixel values in the first array, find the pixel value in the first array that is the same as the pixel value of the background color of the key area, mark the first same pixel value as the first pixel value, and mark the last same pixel value as the second pixel value;
[0093] The pixel value extraction unit is used to extract all pixel values between the first pixel value and the second pixel value in the first array and output them as a second array;
[0094] The output is a key region image unit, which is used to regenerate an image from all pixel values in the second array and output it as a key region image.
[0095] In an optional embodiment of the second aspect of the present invention, the system for generating WhatsApp keys based on OCR recognition further includes:
[0096] The correction and replacement module is used to traverse the key string and correct and replace specific characters in the key string according to a preset character replacement table.
[0097] In an optional embodiment of the second aspect of the present invention, the system for generating WhatsApp keys based on OCR recognition further includes:
[0098] The judgment module is used to determine whether the system language is Arabic; if so, the characters in the key string are reversed and the reversed key string is re-output; if not, the original key string is output.
[0099] In an optional embodiment of the second aspect of the present invention, the import module 40 includes:
[0100] Create a unit to create a byte array;
[0101] An addition unit is used to traverse the key string and add each preset number of digits in the key string as one byte to the byte array;
[0102] The import unit is used to import the added byte array into a local file using a file output stream to obtain a key file.
[0103] In an optional embodiment of the second aspect of the present invention, the identification module 30 includes:
[0104] The input unit is used to input the key area image into the OCR through the OCR interface;
[0105] The text recognition unit is used by the text recognition system in the OCR to recognize the text portion within the key area image and output the text portion as a text-formatted key string.
[0106] Figure 5 This is a schematic diagram of a terminal for generating WhatsApp keys based on OCR recognition, provided by an embodiment of the present invention. The terminal can vary significantly due to differences in configuration or performance, and may include one or more processors 60 (central processing units, CPUs) (e.g., one or more processors) and memory 70, and one or more storage media 80 (e.g., one or more mass storage terminals) for storing applications or data. The memory and storage media can be temporary or persistent storage. The program stored in the storage media may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the terminal. Furthermore, the processor may be configured to communicate with the storage media and execute the series of instruction operations stored in the storage media on the terminal.
[0107] The terminal may also include one or more power supplies 90, one or more wired or wireless network interfaces 100, one or more input / output interfaces 110, and / or one or more operating systems, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 5 The terminal structure shown does not constitute a limitation on the terminal and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0108] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the method for restoring the display of call information.
[0109] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system, device, or unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0110] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer terminal (which may be a personal computer, a terminal, or a network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0111] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural transformations made under the concept of the present invention using the description and drawings of the present invention, or direct / indirect applications in other related technical fields, are included within the patent protection scope of the present invention.
Claims
1. A method for generating WhatsApp keys based on OCR recognition, characterized in that, Includes the following steps: Get the WhatsApp key image; The key area image is captured by distinguishing it by background color in the key image; The key region image is recognized by OCR, and the key string is output. Traverse the key string and correct and replace specific characters in the key string according to the preset character replacement table; And / or, Determine if the system language is Arabic; If so, reverse the characters in the key string and then re-output the reversed key string; If not, output the original key string; Import the key string into a local file to obtain a key file; The process of extracting the key region image from the key image by distinguishing it by background color includes the following steps: Obtain all pixel values from the key image and store them in the first array; Iterate through the pixel values in the first array, find the pixel values in the first array that are the same as the background color pixel values of the key area, mark the first matching pixel value as the first pixel value, and mark the last matching pixel value as the second pixel value; In the first array, all pixel values between the first pixel value and the second pixel value are extracted and output as the second array; Regenerate the image using all pixel values in the second array, and output the result as a key region image.
2. The method for generating WhatsApp keys based on OCR recognition as described in claim 1, characterized in that, The step of importing the key string into a local file to obtain a key file includes the following steps: Create a byte array; Iterate through the key string, adding each preset number of digits in the key string as one byte to the byte array; Import the added byte array into a local file using a file output stream to obtain the key file.
3. The method for generating WhatsApp keys based on OCR recognition as described in claim 1, characterized in that, The key image includes a key area and other areas, and the key area includes key characters; wherein the background color of the key area is different from the background color of the other areas.
4. The method for generating WhatsApp keys based on OCR recognition as described in claim 1, characterized in that, The step of recognizing the key region image using OCR and outputting the key string includes the following steps: The key area image is transmitted to the OCR system via the OCR interface; The text recognition system in the OCR identifies the text portion within the key area image and outputs the text portion as a key string in text format.
5. A terminal for generating WhatsApp keys based on OCR recognition, characterized in that, The terminal includes: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor invokes the instructions in the memory to cause the terminal to execute the method for generating a WhatsApp key based on OCR recognition as described in any one of claims 1-4.
6. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the method for generating WhatsApp keys based on OCR recognition as described in any one of claims 1-4.
Citation Information
Patent Citations
Encrypting and decrypting method and device
CN104967992A
Android application program strengthening method
CN107092816A