Method and system for encrypting read-write card based on NFC and storage medium
By adopting an encrypted reading and writing card method based on NFC in the smart battery swap cabinet, the battery swap problem when the platform crashes and the problem of users forgetting to bring their phones is solved, and a fast, convenient and safe battery swap process is achieved.
Patent Information
- Application Number
- CN202411447728.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-03-11
AI Technical Summary
The existing smart battery swap cabinets are difficult to meet users' battery swap needs when the platform crashes, and users forget to bring their phones and cannot replace them, resulting in inconvenience to users.
The NFC-based encrypted read and write card method is adopted, and the NFC card built into the battery is encrypted and interactively communicated with the NFC sensing area of the battery swap cabinet, thereby realizing battery swap operation without the need for an external platform.
When the platform crashes, users can still meet the battery swap needs. Users can swap without carrying their mobile phones, which improves user convenience and protects the security of user data through encryption algorithms.
Smart Images

Figure CN119599040A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of battery replacement in smart battery exchange cabinets, and specifically to an NFC-based encrypted card reading and writing method, system, and storage medium. Background Art
[0002] The battery swap cabinet is a quick battery replacement product launched for electric vehicle users such as riders, outsourced delivery boys, and couriers. It can help these users quickly replace their electric vehicle batteries.
[0003] Currently, the smart battery swap cabinets on the market include battery swapping methods based on "scanning QR codes" and "face recognition". "Scanning QR codes" and "face recognition" require the platform to be in normal operation and cannot crash. When the platform crashes, the battery swap cabinet will find it difficult to meet the user's battery swap needs. At the same time, users need to bring their mobile phones when swapping batteries. If they forget to bring their mobile phones, they will not be able to continue, which brings many inconveniences to users when swapping batteries. Summary of the Invention
[0004] The purpose of this application is to provide an NFC-based encrypted card reading and writing method, system and storage medium to solve the problem that after the platform crashes, the battery swap cabinet is unable to meet the user's battery swap needs, and the user forgets to bring the mobile phone and cannot swap the battery.
[0005] In order to solve the above problems, this application adopts the following technical solutions:
[0006] The first aspect of the present application provides an NFC-based encrypted card reading and writing method, comprising:
[0007] S1. Turn on the antenna and search for the NFC card.
[0008] S2. Read the NFC card ID and calculate the key based on the NFC card ID, encrypted string and sector ID;
[0009] S3. Write the key to the sector and set read control to complete the encryption;
[0010] S4. When the battery swap cabinet detects the NFC card in the battery, it identifies the NFC card in the battery;
[0011] S5. Determine the key based on the NFC card ID, the encrypted string, and the sector ID, and randomly select a sector for test reading.
[0012] S6. If the sector test is read successfully, find the battery with the highest power in the compartment of the battery exchange cabinet and open the compartment door to return the battery.
[0013] Furthermore, in step S6, if the sector test is read successfully, the battery with the highest power in the battery swap cabinet is found and the door is opened to return the battery. The NFC-based encrypted card reading and writing method includes:
[0014] S7, checking whether the user has returned the battery and waiting for a preset time;
[0015] S8. If, after a preset period of time, it is detected that the user has successfully returned the battery, the door of the battery swap cabinet is closed.
[0016] Furthermore, in step S6, if the sector test is read successfully, the battery with the highest power in the battery swap cabinet is found and the door is opened to return the battery. The NFC-based encrypted card reading and writing method includes:
[0017] S61. If the battery with the highest power level in the battery exchange cabinet is not found, it is indicated that there is no battery available for loan, and the battery return failure is reported to the platform.
[0018] Furthermore, after the step of S5, solving the key based on the ID of the NFC card, the encrypted string and the sector ID, and randomly selecting a sector for test reading, the NFC-based encrypted card reading and writing method includes:
[0019] S51. If the sector test reading is unsuccessful, the NFC card of the battery is indicated as an illegal card and reported to the platform.
[0020] Furthermore, the calculation and solution of the key are based on the ID of the NFC card, the encrypted string and the sector ID, and 16 groups of keys are obtained through MD5 calculation and cyclically written into the sector.
[0021] Furthermore, the encrypted character string is preset in the code.
[0022] Furthermore, after the steps of S1, turning on the antenna and searching for the NFC card, the NFC-based encrypted card reading and writing method includes:
[0023] S11, performing anti-collision detection on the NFC card in the battery;
[0024] S12: If the anti-collision test passes, the NFC card is selected and the ID of the NFC card is read.
[0025] The second aspect of the present application provides an NFC-based encrypted card reader / writer system, comprising:
[0026] The card search module is used to open the antenna field and search for NFC cards;
[0027] A calculation module is used to read the ID of the NFC card and calculate the key based on the ID of the NFC card, the encrypted string and the sector ID;
[0028] The encryption and decryption module is used to write the key into the sector and set the read control to complete the encryption. It is also used to solve the key based on the NFC card ID, the encrypted string and the sector ID when the NFC card is successfully recognized;
[0029] An identification module is used for the battery swap cabinet to detect the NFC card in the battery and identify the NFC card in the battery;
[0030] The door opening and closing module is used to find the battery with the highest power in the compartment of the battery exchange cabinet when the sector test is read successfully, and open the door to return the battery.
[0031] Furthermore, the NFC-based encrypted reading and writing card system includes an exception reporting module, which is used to indicate that there are no batteries available for loan and report to the platform when the battery with the highest power in the battery exchange cabinet is not found. The exception reporting module is also used to indicate that the NFC card of the battery is an illegal card and report to the platform if the sector test read is unsuccessful.
[0032] A third aspect of the present application provides a storage medium storing a computer program, which, when executed by a processor, implements the NFC-based encrypted card reading and writing method as described in any one of the above.
[0033] Compared with the existing technology, the beneficial effect of this application is that: through NFC, the battery swap cabinet can communicate directly with the NFC card in the battery without relying on an external platform, and can still meet the user's battery swap needs when the platform crashes. At the same time, the NFC-based encrypted card reading and writing method does not require users to carry mobile phones, which solves the problem that users forget to bring their mobile phones and cannot swap batteries, and improves user convenience. The NFC card ID, encrypted string and sector ID are used to calculate the key, encrypt the sector, protect the security of user data, prevent NFC cards from being copied, and improve security. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flowchart of an NFC-based encrypted card reading and writing method provided in an embodiment of the present application;
[0035] Figure 2 A flowchart of an NFC card encryption and writing method provided in an embodiment of the present application; and
[0036] Figure 3 This is a flowchart of an NFC card encryption card reading provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The specific implementation methods of this application are described in detail below with reference to the accompanying drawings.
[0038] It should be noted that, unless there is a conflict, the embodiments and technical features in the embodiments of this application can be combined with each other, and the detailed description in the specific implementation method should be understood as an explanation of the purpose of this application and should not be regarded as an improper restriction on this application.
[0039] It should be understood that the orientation or positional relationship is based on the orientation or positional relationship shown in the accompanying drawings. These orientation terms are only used to facilitate the description of this application and simplify the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, they should not be understood as limiting this application.
[0040] At present, the common smart battery swap cabinets on the market include battery swapping methods based on "scanning QR codes" and "face recognition"; among them, the disadvantage of the "scanning QR code" battery swapping method is: when the user comes to the battery swap cabinet, he needs to take out his mobile phone, unlock the screen, find and open the corresponding APP or applet, and find the "scan code" button in the software, and then scan the cabinet QR code to perform the battery swap operation. The steps are cumbersome and inconvenient for those users who are eager to swap batteries; and the disadvantage of the "face recognition" battery swapping method is: before performing face recognition, you need to take off accessories that cover your face, such as helmets and masks. The steps are cumbersome, which brings great trouble to people in battery swapping, and there are disadvantages of difficulty and long battery swapping time.
[0041] In view of this, the present application provides a battery swap system based on NFC to solve the problems brought about by the "battery swap method of scanning QR codes and the battery swap method of face recognition". In the NFC-based battery swap system of the embodiment of the present application, without relying on mobile phone scanning, or when the battery swap cabinet is offline, the NFC tag built into the battery is close to the NFC sensing area of the battery swap cabinet, and the battery swap cabinet reads the NFC tag for encrypted interactive communication. Through a one-card-one-password algorithm, the legitimacy of the battery is confirmed, and the warehouse control system is driven to open the empty warehouse, put in the battery, and take out the new battery. It has an extremely fast warehouse opening speed, and realizes an end-to-end NFC fast battery swap method that does not rely on mobile phone scanning or platform communication verification. For example, the battery swap system can be applied to a battery pack with a metal shell. The battery shell has a built-in NFC anti-metal tag, which is attached to the inner shell wall of the battery. The NFC communication board of the battery swap system is composed of an RFID reader chip, and communicates serially with the 4G communication board of the battery swap cabinet to read and write the NFC anti-metal tag built into the battery shell. The NFC tag's encryption sector is pre-programmed with a key based on an encryption algorithm. This key is calculated using MD5 based on the tag's ID and a key string. It's then written to the third block of the sector and set to be non-readable and non-writable. When the user's battery approaches the battery swap cabinet's NFC sensing area, the key is calculated using the same encryption algorithm based on the readback NFC tag's card ID. This key is then used to read the NFC's encryption sector. If the read is successful, indicating a legitimate battery, the warehouse control system activates the key, allowing the user to insert and remove a new battery, enabling rapid sensing and door-opening battery swapping.
[0042] Figure 1 This is a flowchart of an NFC-based encrypted card reading and writing method provided in an embodiment of the present application. Figure 2 This is a flowchart of an NFC card encryption and writing method provided in an embodiment of the present application. Figure 3 This is a flowchart of an NFC card encryption card reading provided by the embodiment of the present application. Figures 1 to 3 As shown, the embodiment of the present application provides an NFC-based encrypted card reading and writing method, including:
[0043] S1. Turn on the antenna and search for the NFC card.
[0044] S2. Read the NFC card ID and calculate the key based on the NFC card ID, encrypted string and sector ID;
[0045] S3. Write the key to the sector and set read control to complete the encryption;
[0046] S4. When the battery swap cabinet detects the NFC card in the battery, it identifies the NFC card in the battery;
[0047] S5. Decode the key based on the NFC card ID, encrypted string, and sector ID, and randomly select a sector for test reading.
[0048] S6. If the sector test is read successfully, find the battery with the highest power in the battery swap cabinet and open the door to return the battery.
[0049] Specifically, an NFC card is embedded in the battery of the electric vehicle. The NFC card stores a unique ID and an encrypted string. The antenna is turned on to search for the NFC card, read the ID of the NFC card, and calculate the key based on the ID of the NFC card, the encrypted string and the sector ID. The key is written into the sector and the reading control is set to complete the encryption. This process is completed in advance before the battery is packaged. When the battery that needs to be replaced is close to the battery swap cabinet, for example, the side of the battery with the NFC card is close to the card reading area on the battery swap cabinet, so that the battery swap cabinet monitors the NFC card in the battery and identifies the NFC card in the battery. The battery is in the NFC card. The battery swap cabinet reads the key stored in the NFC card and randomly selects a sector for test reading. A successful test read indicates that the data in the NFC card has not been tampered with and is available. If the sector test read is successful, the battery swap cabinet looks for the battery with the highest power and opens the door for the user to replace the battery.
[0050] By placing the NFC tag (NFC card) built into the battery close to the NFC sensing area of the battery swap cabinet, the battery swap cabinet reads the NFC tag for encrypted interactive communication, and uses a one-card-one-key algorithm to confirm the legitimacy of the battery, driving the warehouse control system to open the empty warehouse, put in the battery, and take out the new battery, realizing an end-to-end NFC fast battery swap method that does not rely on mobile phone scanning or platform communication verification. As a result, the battery can be quickly swapped by simply placing it close to the NFC sensing area of the battery swap cabinet, simplifying the battery swap operation. At the same time, the built-in encryption algorithm and the encryption sector of the NFC tag improve the security of the system.
[0051] It should be noted that NFC tags are anti-metal tags and can be used on metal battery casings. Furthermore, the battery verification process, based on card reader legitimacy, does not rely on platform verification. It is very fast, sensing and opening the door in approximately 0.5 seconds. Even if the device (battery swap cabinet) is offline, the door can be opened and the battery returned. This is done through a unique encrypted communication method to verify the legitimacy of the battery. Fast sensing requires no platform verification and requires anti-copying. The cabinet uses an encrypted communication algorithm to identify and open the door. Even without platform verification, fast sensing is possible and anti-copying is also possible. For example, a key must first be written to the tag. Each card has a unique key and cannot be copied. The cabinet (battery swap cabinet) uses an encryption algorithm to mutually recognize the tag as an invalid card. During the identification process, the cabinet will identify the card as an illegal (duplicate card), sound a warning tone, and will not open the cabinet or door. It is important to note that even if the platform is completely down, NFC battery swapping can still be used. No phone is required; as long as the battery is present, a battery swap (replacement) can be performed.
[0052] In some embodiments, after S6, if the sector test read is successful, finding the battery with the highest power in the battery swap cabinet and opening the door to return the battery, the NFC-based encrypted card reading and writing method includes:
[0053] S7, checking whether the user has returned the battery and waiting for a preset time;
[0054] S8. If after the preset time, it is detected that the user has successfully returned the battery, the door of the battery swap cabinet will be closed.
[0055] Specifically, the system will configure multiple battery compartments in the battery swap cabinet, each of which stores batteries with a certain amount of power. Each battery is identified by an NFC tag and associated with the user's return reader-writer card. When the user arrives at the battery swap cabinet with the battery, the sensor of the battery swap cabinet will detect the user's presence and trigger step S6. In step S6, the card reader of the battery swap cabinet will try to communicate with the NFC card inside the battery that wants to be swapped through NFC technology to read the information therein. If the read is successful, step S7 is entered. In step S7, the system will detect the battery information returned by the user and wait for a preset time, for example, 2 minutes. During the waiting period, the user needs to ensure that the battery remains connected to the reader-writer card. After the preset time expires, the system will enter step S8. In step S8, the system will detect the battery information returned by the user again. If the battery information is detected to be consistent with the preset return success standard, it is determined that the user has successfully returned the battery. Subsequently, the system will close the compartment door of the battery swap cabinet to complete the entire battery return process.
[0056] In some embodiments, after S6, if the sector test read is successful, finding the battery with the highest power in the battery swap cabinet and opening the door to return the battery, the NFC-based encrypted card reading and writing method includes:
[0057] S61. If the battery with the highest power level in the battery swap cabinet is not found, it will indicate that there are no batteries available for loan, and report to the platform that the battery return has failed.
[0058] Specifically, in step S61, the system will query the power information of all battery compartments in the battery swap cabinet to find the battery with the highest power. If the battery with the highest power is not found, the system will indicate that there is no battery available for loan and report to the platform that the battery return has failed. If the battery with the highest power is found, the system will open the corresponding battery compartment door so that the user can return the battery. After the battery is returned, the system will close the compartment door, completing the entire battery return process.
[0059] In some embodiments, after the steps of S5, determining the key based on the NFC card ID, the encrypted string, and the sector ID, and randomly selecting a sector for test reading, the NFC-based encrypted card reading and writing method includes:
[0060] S51. If the sector test reading is unsuccessful, the NFC card of the battery is indicated as an illegal card and reported to the platform.
[0061] Specifically, each battery is equipped with an NFC card that stores a unique ID and an encrypted string. When the user attempts to return the battery, the system triggers step S5. In step S5, the system uses the user's NFC card ID, encrypted string, and sector ID to solve the key used for encryption and decryption. The system randomly selects a sector for test reading. If the sector test read fails in step S51, it means that there may be a problem with the battery's NFC card. The system will indicate that the battery's NFC card is an illegal card and report it to the platform.
[0062] In some embodiments, the calculation and solution of the key are based on the ID of the NFC card, the encrypted string and the sector ID, and 16 groups of keys are obtained through MD5 calculation and written into the sector in a loop.
[0063] Specifically, when encrypting or decrypting the battery, the system triggers a key calculation step. During this step, the system uses the NFC card ID, the encryption string, and the sector ID as input parameters to generate 16 sets of keys through an MD5 operation. During the cyclic sector write step, the system cyclically writes these 16 sets of keys to the NFC card sectors, enhancing data security. The encryption string is pre-set in the code.
[0064] In some embodiments, after the steps of S1, turning on the antenna and searching for the NFC card, the NFC-based encrypted card reading and writing method includes:
[0065] S11, performing anti-collision detection on the NFC card in the battery;
[0066] S12: If the anti-collision test passes, select the NFC card and read the ID of the NFC card.
[0067] Specifically, the antenna field needs to be turned on first in order to communicate with the NFC card. The function of the antenna field is to create an NFC communication area so that the NFC card can sense the area and exchange data with it. After turning on the antenna field, the system will enter step S11 to perform anti-collision detection on the NFC card in the battery. In step S11, the system will send a specific signal to identify and select the target NFC card. By detecting the response of the signal, the system can determine whether there are multiple NFC cards responding at the same time, and determine the ID of the NFC card to communicate. If the anti-collision detection passes, that is, the system successfully selects the target NFC card, it will enter step S12. In step S12, the system will read the ID of the selected NFC card. After reading the ID of the NFC card, the system can continue to perform subsequent encrypted read and write operations, such as encrypting the battery data or verifying the legitimacy of the NFC card.
[0068] The present application provides an NFC-based encrypted card reader / writer system, including:
[0069] The card search module is used to open the antenna field and search for NFC cards;
[0070] A calculation module is used to read the ID of the NFC card and calculate the key based on the ID of the NFC card, the encrypted string and the sector ID;
[0071] The encryption and decryption module is used to write the key to the sector and set the read control to complete the encryption. It is also used to solve the key based on the NFC card ID, encrypted string and sector ID when the NFC card is successfully recognized;
[0072] Identification module, used for the battery swap cabinet to detect and identify the NFC card in the battery;
[0073] The compartment door opening and closing module is used to find the battery with the highest power in the compartment of the battery swap cabinet when the sector test is read successfully, and open the compartment door to return the battery.
[0074] In some embodiments, the NFC-based encrypted reading and writing card system includes an exception reporting module, which is used to indicate that there are no batteries available for loan and report to the platform when the battery with the highest power in the battery swap cabinet is not found. The exception reporting module is also used to indicate that the NFC card of the battery is an illegal card and report to the platform if the sector test read is unsuccessful.
[0075] An embodiment of the present application further provides a storage medium storing a computer program, which, when executed by a processor, implements any of the above-mentioned NFC-based encrypted card reading and writing methods.
[0076] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the above embodiments, or to replace some of the technical features therein with equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions claimed to be protected by the present application.
Claims
1. A method for reading and writing encrypted cards based on NFC, characterized in that: include: S1. Turn on the antenna and search for the NFC card. S2, read the ID of the NFC card, and calculate the key based on the ID of the NFC card, the encrypted string and the sector ID; S3, write the key into the sector and set the read control to complete the encryption; S4. When the battery swap cabinet detects the NFC card in the battery, identify the NFC card in the battery; S5. Based on the ID of the NFC card, the encrypted string and the sector ID, a key is solved, and a sector is randomly selected for test reading; S6. If the sector test is read successfully, find the battery with the highest power in the compartment of the battery exchange cabinet and open the compartment door to return the battery.
2. The method for reading and writing encrypted cards based on NFC according to claim 1, characterized in that: S6. If the sector test is read successfully, then find the battery with the highest power in the compartment of the battery swap cabinet and open the compartment door to return the battery. After that, the NFC-based encrypted card reading and writing method includes: S7, detecting the user returning the battery and waiting for a preset time; S8. If after a preset period of time, it is detected that the user has successfully returned the battery, the door of the battery exchange cabinet is closed.
3. The method for reading and writing encrypted cards based on NFC according to claim 2, characterized in that: S6. If the sector test is read successfully, then find the battery with the highest power in the compartment of the battery swap cabinet and open the compartment door to return the battery. After that, the NFC-based encrypted card reading and writing method includes: S61. If the battery with the highest power level in the battery swap cabinet is not found, it is indicated that there are no batteries available for loan, and the battery return failure is reported to the platform.
4. The method for reading and writing encrypted cards based on NFC according to claim 1, characterized in that: S5, after the steps of solving the key based on the ID of the NFC card, the encrypted string and the sector ID, and randomly selecting a sector for test reading, the NFC-based encrypted card reading and writing method includes: S51. If the sector test reading fails, it indicates that the NFC card of the battery is an illegal card and reports to the platform.
5. The method for reading and writing encrypted cards based on NFC according to claim 1, characterized in that: The calculation and solution of the key are based on the ID of the NFC card, the encrypted string and the sector ID. 16 groups of keys are obtained through MD5 calculation and written into the sector in a loop.
6. The method for reading and writing encrypted cards based on NFC according to claim 5, characterized in that: The encrypted string is preset in the code.
7. The method for reading and writing encrypted cards based on NFC according to claim 1, characterized in that: After the steps of S1, turning on the antenna and searching for the NFC card, the NFC-based encrypted card reading and writing method includes: S11, performing anti-collision detection on the NFC card in the battery; S12: If the anti-collision detection passes, the NFC card is selected and the ID of the NFC card is read.
8. An encrypted card reading and writing system based on NFC, characterized in that: include: The card search module is used to open the antenna transmission field and search for NFC cards; A calculation module, used for reading the ID of the NFC card and calculating a key based on the ID of the NFC card, the encrypted string and the sector ID; The encryption and decryption module is used to write the key into the sector and set the read control to complete the encryption, and is also used to solve the key based on the ID of the NFC card, the encrypted string and the sector ID when the NFC card is successfully identified; An identification module is used for the battery swap cabinet to detect the NFC card in the battery and identify the NFC card in the battery; The compartment door opening and closing module is used to find the battery with the highest power in the compartment of the power exchange cabinet when the sector test is read successfully, and open the compartment door to return the battery.
9. The NFC-based encrypted card reading and writing system according to claim 8, characterized in that: The NFC-based encrypted card reading and writing system includes an exception reporting module, which is used to indicate that there are no batteries available for loan and report to the platform when the battery with the highest power in the compartment of the power exchange cabinet is not found. The exception reporting module is also used to indicate that the NFC card of the battery is an illegal card and report to the platform if the sector test read fails.
10. A storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, the encrypted card reading and writing method based on NFC as described in any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Battery processing method and device based on battery identity binding and electronic equipment
CN121940193A