A method for generating a device identifier, a vehicle
By generating a random number-based device identifier in the vehicle communication terminal and adjusting it in combination with hardware and message attribute information, the problem that the vehicle communication terminal cannot generate a unique identifier is solved, and the accurate identification of devices and processes is achieved.
Patent Information
- Application Number
- CN202510488013.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-04-18
AI Technical Summary
Due to resource and cost limitations, vehicle-mounted communication terminals cannot call the standard equipment identifier library to generate unique equipment identifiers, resulting in the inability to accurately identify the data source, which brings difficulties to device management and data tracking.
By generating a random number-based device identifier, and combining the hardware attribute information of the first device and the message attribute information of the message to be sent, the characters in the identifier are adjusted to generate a target device identifier to indicate the message source.
Without relying on the device identifier library, a target device identifier with high uniqueness is generated to ensure that the second device can accurately identify the source device or process, solving the problem of the innate identifier.
Smart Images

Figure CN120012174B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of identity recognition of embedded devices, and more particularly, to a method for generating a device identifier and a vehicle. Background Art
[0002] In the field of embedded devices, especially in in-vehicle communication terminals (Telematics Box, TBox), the generation of device identifiers (such as Universally Unique Identifier (UUID)) is a key technical issue.
[0003] Due to resource and cost limitations, in-vehicle communication terminals often cannot call a standard device identifier library to generate unique identifiers. If the device identifiers are not unique, it will be impossible to accurately identify the in-vehicle communication terminals from which the data sources are, which brings difficulties to the device management and data tracking of in-vehicle communication terminals. Summary of the Invention
[0004] The present application aims to provide a method for generating a device identifier and a vehicle, which are capable of generating device identifiers with high uniqueness without relying on a third-party device identifier library.
[0005] In a first aspect of the present application, a method for generating a device identifier is provided, which is applied to a first device. The method includes:
[0006] Generating a first device identifier based on a random number for a message to be sent to a second device;
[0007] Adjusting characters in the first device identifier according to hardware attribute information of hardware components deployed in the first device and / or message attribute information of the message to be sent, to obtain a target device identifier, where the target device identifier is used to indicate to the second device that the message to be sent comes from the first device.
[0008] In an optional implementation manner, the first device identifier includes at least N characters, and each character occupies one character position. Generating a first device identifier based on a random number for a message to be sent to a second device includes:
[0009] Initializing a raw device identifier including at least N character positions, where characters at each character position of the raw device identifier are initial characters;
[0010] Obtaining a timestamp corresponding to the message to be sent, where the timestamp represents the generation moment of the message content of the message to be sent or the sending moment of the message to be sent;
[0011] Generate N random numbers based on the time stamp;
[0012] Based on the nth random number, extract a character from the character set for the nth character position of the original device identifier, where the character set includes a plurality of different characters, and n ranges from 1 to N;
[0013] Fill the character extracted in the nth character position of the original device identifier to obtain a first device identifier based on the random numbers.
[0014] In an alternative embodiment, extracting a character from the character set for the nth character position of the original device identifier based on the nth random number includes:
[0015] Determine an index value for the nth character position of the original device identifier based on the nth random number and the total number of characters in the character set;
[0016] Extract a character corresponding to the index value of the nth character position of the original device identifier from the character set, where different characters in the character set correspond to different index values.
[0017] In an alternative embodiment, the first device identifier further includes M target characters, and the original device identifier further includes M target character positions. Each target character occupies one target character position, and the target characters are different from the characters in the character set; before extracting a character from the character set for the nth character position of the original device identifier based on the nth random number, the method further includes:
[0018] Fill each of the M target character positions of the original device identifier with the target characters;
[0019] Filling the character extracted in the nth character position of the original device identifier to obtain a first device identifier based on the random numbers includes:
[0020] Fill the character extracted in the nth character position of the original device identifier except for the M target character positions to obtain a first device identifier based on the random numbers.
[0021] In an alternative embodiment, the first device identifier further includes M target characters. Adjust the characters in the first device identifier according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent to obtain a target device identifier, including:
[0022] Adjust multiple characters in the first device identifier except the M target characters according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, to obtain a target device identifier.
[0023] In an optional implementation manner, adjusting the characters in the first device identifier according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent to obtain a target device identifier includes:
[0024] Determine a first string characterizing the hardware attribute information; and / or, obtain a message number corresponding to the message to be sent and determine a second string characterizing the message number; the message number increases as the total number of messages sent from the first device to the second device increases;
[0025] Use the first string to adjust multiple first characters in the first device identifier, and / or use the second string to adjust multiple second characters in the first device identifier, to obtain a target device identifier, where the character positions of the multiple first characters do not overlap with the character positions of the multiple second characters.
[0026] In an optional implementation manner, after obtaining the target device identifier, the method further includes:
[0027] Obtain the hardware utilization rate of the first device, where the hardware utilization rate includes at least one of the following: CPU utilization rate, memory utilization rate;
[0028] When the hardware utilization rate is less than a first threshold, encrypt the target device identifier using a first encryption method;
[0029] When the hardware utilization rate is greater than or equal to the first threshold and less than a second threshold, encrypt the target device identifier using a second encryption method, where the hardware resource consumption of the second encryption method is lower than that of the first encryption method, and the second threshold is greater than the first threshold;
[0030] When the hardware utilization rate is greater than or equal to the second threshold, determine not to encrypt the target device identifier using any encryption method.
[0031] In an optional implementation manner, the method further includes:
[0032] Generate encryption prompt information according to whether the target device identifier is encrypted and the encryption method used when encrypting the target device identifier;
[0033] Generate a target message according to the encrypted prompt information, the target device identifier, and the message content of the message to be sent;
[0034] Send the target message to the second device.
[0035] In an alternative embodiment, the method further includes:
[0036] Determine the message type of the message to be sent;
[0037] Generate a first device identifier based on a random number for a message to be sent to a second device, including:
[0038] When the message type belongs to a target message type, generate a first device identifier based on a random number for the message to be sent, where the target message type includes any one of the following: login message type, logout message type, sleep message type, wake-up message type, remote control response message type, reservation vehicle control message type, OTA upgrade message type.
[0039] A second aspect of the present application provides a vehicle, including:
[0040] A memory storing the vehicle identification number of the vehicle;
[0041] An in-vehicle terminal for using the vehicle identification number of the vehicle as the hardware attribute information of the hardware components deployed inside the first device, and performing the steps of implementing the device identifier generation method in the first aspect of the present application.
[0042] A third aspect of the present application provides a device identifier generation device applied to a first device, the device including:
[0043] A first processing module for generating a first device identifier based on a random number for a message to be sent to a second device;
[0044] A second processing module for adjusting the characters in the first device identifier according to the hardware attribute information of the hardware components deployed inside the first device and / or the message attribute information of the message to be sent, to obtain a target device identifier, where the target device identifier is used to indicate to the second device that the message to be sent comes from the first device.
[0045] A fourth aspect of the present application provides an electronic device, including: a processor, a memory, and a computer program stored on the memory and executable on the processor, where the processor implements the device identifier generation method in the first aspect of the present application when executing the computer program.
[0046] The fifth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the device identifier generation method according to the first aspect of the present application is implemented.
[0047] The sixth aspect of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the device identifier generation method according to the first aspect of the present application is implemented.
[0048] In the device identifier generation method provided by the present application, for a message to be sent to a second device, a first device identifier based on a random number is generated; according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, the characters in the first device identifier are adjusted to obtain a target device identifier, and the target device identifier is used to indicate to the second device that the message to be sent comes from the first device. By combining the hardware attribute information and / or the message attribute information to adjust the characters in the first device identifier based on a random number, a target device identifier with high uniqueness can be generated, avoiding reliance on a device identifier library; the generated target device identifier helps the second device accurately identify the message source device. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0050] Figure 1 is a flowchart of the steps of the device identifier generation method proposed in an embodiment of the present application;
[0051] Figure 2 is a flowchart of the steps of generating a first device identifier based on a random number in the device identifier generation method proposed in an embodiment of the present application;
[0052] Figure 3 is a schematic diagram of the comprehensive CPU usage rate and encryption algorithm in the device identifier generation method proposed in an embodiment of the present application;
[0053] Figure 4 is a schematic structural diagram of the device identifier generation device proposed in an embodiment of the present application;
[0054] Figure 5 is a schematic diagram of an electronic device proposed in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0055] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.
[0056] In the accompanying drawings, sometimes for clarity, the sizes of the constituent elements, the thicknesses of the layers, or the regions may be exaggerated. Therefore, any implementation of the present disclosure is not necessarily limited to the sizes shown in the figures, and the shapes and sizes of the components in the figures do not reflect the true proportions. In addition, the accompanying drawings schematically show ideal examples, and any implementation of the present disclosure is not limited to the shapes or values shown in the accompanying drawings.
[0057] When the in-vehicle communication terminal TBox sends a message (such as a login / logout message) to the server, a device identifier string with a length of 36 characters, such as a UUID string, needs to be attached to the content for both parties to jointly check the problem. Due to limited resources and costs, the TBox cannot call the device identifier library to generate a unique device identifier.
[0058] In view of the above problems, the embodiments of the present application propose a device identifier generation method and a vehicle to generate a device identifier with high uniqueness without relying on a third-party device identifier library. Next, in conjunction with the accompanying drawings, a device identifier generation method and a vehicle provided by the embodiments of the present application will be described in detail through some embodiments and their application scenarios.
[0059] Refer to Figure 1 , Figure 1 is a flowchart of the steps of the device identifier generation method proposed in an embodiment of the present application. As Figure 1 shown, this method is applied to the first device and includes the following steps S11~S12:
[0060] Step S11: Generate a first device identifier based on a random number for the message to be sent to the second device.
[0061] In this embodiment, the first device is an embedded device, such as a vehicle-mounted communication terminal; the second device is a device that interacts with the first device, such as a server. During the information interaction between the first device and the second device, for the message to be sent from the first device to the second device, a first device identifier based on a random number corresponding to the first device can be generated through a random number algorithm. Herein, the message to be sent in this embodiment is a message that the first device has prepared but has not been actually transmitted to the second device. For example, the message to be sent can be a login, logout message, OTA upgrade message, etc. The first device identifier based on a random number in this embodiment refers to a device identifier generated through a random number algorithm. In an alternative embodiment, the device identifier is a UUID.
[0062] Step S12: Adjust the characters in the first device identifier according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, to obtain a target device identifier, where the target device identifier is used to indicate to the second device that the message to be sent comes from the first device.
[0063] In this embodiment, for the hardware attribute information, the attribute information (such as serial number, model, manufacturer information, etc.) can be read from the hardware components of the first device (such as CPU, motherboard, network interface card, etc.). These information can usually be obtained through the API (Application Programming Interface) provided by the operating system of the first device. For the message attribute information, the attribute information can be extracted according to the content or metadata of the message to be sent, and this attribute information refers to the key elements that describe the message characteristics, message transmission behavior, and implementation of business logic, such as including: message type, message identifier, transmission protocol, etc.
[0064] According to a preset rule or algorithm, and the obtained hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, adjust the characters in the first device identifier to obtain a target device identifier, where the target device identifier is used to indicate to the second device that the message to be sent comes from the first device. In this embodiment, the adjustment can include but is not limited to: various methods such as replacement, mapping, padding, deletion, encoding, etc.
[0065] For example, when the adjustment operation is mapping, in an alternative implementation manner, a specific position in the first device identifier can be selected based on the hardware attribute information and / or the message attribute information, and based on the mapping relationship corresponding to the hardware attribute information and / or the message attribute information, the characters at the specific position are mapped to the corresponding characters to obtain the target device identifier.
[0066] When the adjustment operation is deletion, in an alternative embodiment, one or more character positions to be deleted in the first device identifier may be determined based on the hardware attribute information and / or the message attribute information, and the characters at the character positions to be deleted in the first device identifier are deleted to obtain the target device identifier.
[0067] When the adjustment operation is replacement, in an alternative embodiment, the preset replacement rule may be formulated based on the hardware attribute information and / or the message attribute information. For example, the characters at specific positions (such as the beginning, the end, or a certain segment in the middle) in the device identifier may be selected for bit-by-bit replacement. During the replacement process, the basic format and length of the device identifier may be kept unchanged to ensure that the replaced device identifier is still readable and recognizable.
[0068] In the device identifier generation method provided in this application, for a message to be sent to a second device, a first device identifier based on a random number is generated; according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, the characters in the first device identifier are adjusted to obtain a target device identifier, and the target device identifier is used to indicate to the second device that the message to be sent comes from the first device. By combining the hardware attribute information and / or the message attribute information to adjust the characters in the first device identifier based on a random number, a target device identifier with high uniqueness can be generated, avoiding relying on a device identifier library; the generated target device identifier helps the second device accurately identify the message source device.
[0069] In the device identifier generation methods of related technologies, in addition to the fact that vehicle-mounted communication terminals often cannot call a standard device identifier library to generate unique device identifiers due to resource and cost limitations, it may also be the case that the generated device identifiers are not unique due to situations such as different vehicle-mounted communication terminals starting at the same timestamp.
[0070] For example, the current method of generating device identifiers based on random numbers may face the following problems:
[0071] Example 1: Under normal circumstances, different vehicle-mounted communication terminals correspond to different device identifiers. However, if different vehicle-mounted communication terminals power on at the same second, it is very likely that different vehicle-mounted communication terminals will generate the same device identifier (if the two timestamps are exactly the same, the results generated by the random number algorithm based on the timestamp are very likely to be the same).
[0072] Example 2: Under normal circumstances, different processes in the same vehicle-mounted communication terminal correspond to different device identifiers. However, if two different processes are started within the same second in the same vehicle-mounted communication terminal, there is a high probability that the same device identifier will be generated (if the timestamps used by the two processes are exactly the same, the results generated by the random number algorithm based on the timestamp are likely to be the same).
[0073] Based on this, the present application proposes a device identifier generation method. For a message to be sent to a second device, a first device identifier based on a random number is generated; according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, the characters in the first device identifier are adjusted to obtain a target device identifier. In this way, on the basis of avoiding reliance on a device identifier library, for a message to be sent to a second device, a first device identifier based on a random number is generated, and different first device identifiers can be generated as much as possible for different messages to be sent. Then, by combining the hardware attribute information and / or the message attribute information, the characters in the first device identifier based on the random number are adjusted, and the target device identifier obtained after adjustment carries the mapping relationship with the hardware attribute information and / or the message attribute information.
[0074] On the one hand, different hardware attribute information corresponding to different devices is built into the second device. After receiving the target device identifier, the second device identifies the target device identifier according to the mapping relationship carried by the target device identifier, and identifies the hardware attribute information of the device, so as to accurately identify the message source device corresponding to the target device identifier (such as device A or device B).
[0075] Taking the above Example 1 as an example, vehicle-mounted communication terminal A and vehicle-mounted communication terminal B are powered on at the same time within the same second. The first target device identifier adjusted based on the hardware attribute information of vehicle-mounted communication terminal A carries the mapping relationship with the hardware attribute information of vehicle-mounted communication terminal A. The second device identifies the first target device identifier according to the mapping relationship carried by the first target device identifier, and identifies the hardware attribute information of vehicle-mounted communication terminal A. Further, based on the different hardware attribute information corresponding to different devices built into the second device, it is determined that the message source device corresponding to the first target device identifier is vehicle-mounted communication terminal A; the second target device identifier adjusted based on the hardware attribute information of vehicle-mounted communication terminal B carries the mapping relationship with the hardware attribute information of vehicle-mounted communication terminal B. The second device identifies the second target device identifier according to the mapping relationship carried by the second target device identifier, and identifies the hardware attribute information of vehicle-mounted communication terminal B. Further, based on the different hardware attribute information corresponding to different devices built into the second device, it is determined that the message source device corresponding to the second target device identifier is vehicle-mounted communication terminal B.
[0076] Even if the first device identifiers based on random numbers are the same, adopting the technical solution of this application, the target device identifiers adjusted based on different hardware attribute information corresponding to different devices are different. Continuing with the above Example 1, because the hardware attribute information of in-vehicle communication terminal A is unique and cannot be the same as the hardware attribute information of other in-vehicle communication terminals (e.g., in-vehicle communication terminal B), the first target device identifier adjusted based on the hardware attribute information of in-vehicle communication terminal A is different from the second target device identifier adjusted based on the hardware attribute information of in-vehicle communication terminal B. The target device identifier generated by adopting the technical solution of this application has high uniqueness.
[0077] On the other hand, different message attribute information corresponding to different message source processes is built into the second device. After receiving the target device identifier, the second device identifies the message attribute information of the message source process according to the mapping relationship carried by the target device identifier, so as to accurately identify the message source process corresponding to the target device identifier (such as the OTA remote control process or the logout process in the in-vehicle communication terminal).
[0078] Taking the above Example 2 as an example, the OTA remote control process and the logout process in the in-vehicle communication terminal are started at the same second. The third target device identifier adjusted based on the message attribute information of the OTA remote control process carries the mapping relationship with the message attribute information of the OTA remote control process. The second device identifies the third target device identifier according to the mapping relationship carried by the third target device identifier, identifies the message attribute information of the OTA remote control process, and further determines that the message source process corresponding to the third target device identifier is the OTA remote control process based on the different message attribute information corresponding to different message source processes built into the second device; the fourth target device identifier adjusted based on the message attribute information of the logout process carries the mapping relationship with the message attribute information of the logout process. The second device identifies the fourth target device identifier according to the mapping relationship carried by the fourth target device identifier, identifies the message attribute information of the logout process, and further determines that the message source process corresponding to the fourth target device identifier is the logout process based on the different message attribute information corresponding to different message source processes built into the second device.
[0079] Even if the first device identifiers based on random numbers are the same, by adopting the technical solution of this application, the target device identifiers adjusted based on different message attribute information corresponding to different message source processes are different. Continuing with the above Example 2, since the message attribute information of the OTA remote control process is unique and cannot be the same as the message attribute information of other message source processes (for example: logout process), the third target device identifier adjusted based on the message attribute information of the OTA remote control process is different from the fourth target device identifier adjusted based on the message attribute information of the logout process. The target device identifiers generated by adopting the technical solution of this application have high uniqueness.
[0080] In this way, through the device identifier generation method proposed in this application, a target device identifier with high uniqueness can be generated, avoiding reliance on a device identifier library.
[0081] In one implementation, this application also provides a device identifier generation method. The first device identifier includes at least N characters, and each character occupies one character position. In this method, the above step S11, "For a message to be sent to a second device, generate a first device identifier based on a random number", may specifically include the following steps S21 to S25:
[0082] Step S21: Initialize an original device identifier including at least N character positions, and the characters at each character position of the original device identifier are initial characters.
[0083] In this embodiment, first, the original device identifier is initialized. The initialized original device identifier includes at least N character positions, and the characters at each character position of the original device identifier are initial characters. Among them, the initial characters can be randomly set to any characters, or the initial characters are all null values. This embodiment does not limit this.
[0084] In this embodiment, the at least N character positions included in the initialized original device identifier correspond to the at least N characters included in the first device identifier to be generated. N is an integer greater than 1, and the specific value of N can be determined based on the device type of the first device. Different device types can correspond to different specific values of N. For example, when the first device is a vehicle-mounted communication terminal, its corresponding device identifier is usually a 128-bit value, represented as 32 hexadecimal characters in the standard format. At this time, N in this embodiment can be 32, that is, the first device identifier includes at least 32 characters, and each character occupies one character position. Then, an original device identifier including at least 32 character positions needs to be initialized.
[0085] Step S22: Obtain the timestamp corresponding to the message to be sent, where the timestamp represents the generation moment of the message content of the message to be sent or the sending moment of the message to be sent.
[0086] In this embodiment, on the first device, the timestamp corresponding to the message to be sent can be obtained through the system clock, and the timestamp represents the generation moment of the message content of the message to be sent or the sending moment of the message to be sent. For example, if the message to be sent is a login message, when the first device process starts or the device starts, it will trigger the generation and sending of the login message. At this time, the generation moment or the sending moment of the login message can be used as the timestamp. For another example, in some other scenarios (such as logout, OTA upgrade scenarios, etc.), the first device will trigger the generation and sending of the message to be sent. At this time, the generation moment or the sending moment of the message to be sent is also used as the timestamp.
[0087] Step S23: Generate N random numbers based on the timestamp.
[0088] In this embodiment, taking this timestamp as the seed of the random number generator, N random numbers can be generated based on the timestamp through multiple random number algorithms (including but not limited to: random number generation seeded by the time function (srand(time) function), standard library pseudo-random number generation (Pseudo-Random Number Generators, PRNGs), cryptographically secure pseudo-random number generation (Cryptographically Secure Pseudo-Random Number Generators, CSPRNGs), etc.). Among them, the srand(time) function is called once at the beginning of the program to set the seed of the random number generator, and subsequent random number generation is achieved by calling the srand(time) function.
[0089] Step S24: Based on the nth random number, extract a character from the character set for the nth character position of the original device identifier, where the character set includes multiple different characters, and the value of n ranges from 1 to N.
[0090] In this embodiment, a character set including multiple different characters is predefined in advance, such as including numbers, letters, etc. According to the nth random number based on the timestamp, a character is extracted from the character set for the nth character position of the original device identifier, and the value of n ranges from 1 to N. N is the number of characters of the first device identifier, and N = 32.
[0091] Step S25: Fill the extracted character in the nth character position of the original device identifier to obtain the first device identifier based on the random number.
[0092] In this embodiment, for the nth character position of the original device identifier, the characters extracted in step S24 are filled in the corresponding nth character position of the original device identifier until all character positions in the original device identifier are filled, and a first device identifier based on random numbers is obtained.
[0093] In an alternative embodiment, when generating N random numbers, not only can N random numbers be generated based on the timestamp through multiple random number algorithms, but also N random numbers can be generated based on the message content itself of the message to be sent through multiple random number algorithms, and N random numbers can also be generated based on the message sequence identifier of the message to be sent (i.e., the sequential number of the message to be sent in communication), and so on. This embodiment does not limit the generation method of random numbers.
[0094] In one embodiment, the present application also provides a method for generating a device identifier. In this embodiment, the above step S24, "Based on the nth random number, for the nth character position of the original device identifier, extract a character from the character set" may specifically include step S31 and step S32:
[0095] Step S31: Based on the nth random number and the total number of characters in the character set, determine the index value of the nth character position of the original device identifier.
[0096] In this embodiment, the index value of the nth character position of the original device identifier can be determined based on the nth random number and the total number of characters in the predefined character set. In an alternative embodiment, the remainder of the nth random number divided by the total number of characters in the predefined character set can be taken to obtain the index value of the nth character position of the original device identifier.
[0097] For example, when the first device is a vehicle-mounted communication terminal, the standard format requirement for the device identifier corresponding to the vehicle-mounted communication terminal is to use hexadecimal digits. Therefore, a character set (character filling alternative pool) including 16 characters can be predefined. For example, the character set chars can be expressed as: chars = "0123456789abcdef". Correspondingly, the remainder of the generated nth random number divided by 16 is taken to obtain an integer ranging from 0 to 15 as the index value, that is, the index value of the nth character position of the original device identifier is determined.
[0098] Step S32: Extract a character corresponding to the index value of the nth character position of the original device identifier from the character set, and different characters in the character set correspond to different index values.
[0099] In this embodiment, for the n-th character position of the original device identifier, the index value obtained in step S31 is used to extract the character corresponding to the index value from the character set (such as the chars string). Different characters in the character set correspond to different index values. Then, the extracted corresponding character is filled into the n-th character position in the original device identifier. For example, if the index value calculated at the 9th character position of the original device identifier is 2, then based on the index value 2, the value of chars[2] in the character set is 1, and the 9th character position of the original device identifier can be set to "2"; if the index value calculated at the 14th character position of the original device identifier is 15, then based on the index value 15, the value of chars
[15] in the character set is f, and the 14th character position of the original device identifier can be set to "f".
[0100] In one implementation, the present application further provides a method for generating a device identifier. In this embodiment, the above step S24 "based on the n-th random number, for the n-th character position of the original device identifier, extract a character from the character set" may specifically include the following steps:
[0101] After determining the index value of the n-th character position of the original device identifier based on the n-th random number and the total number of characters in the character set, randomly shuffle the index values corresponding to the characters in the character set, and then extract a character corresponding to the index value of the n-th character position from the character set. In this way, in each time of extracting a character from the character set based on a random number in this embodiment, the index values corresponding to the characters in the character set are randomly shuffled, which can improve the randomness of the first device identifier to further ensure the high uniqueness of the target device identifier.
[0102] In one implementation, the present application further provides a method for generating a device identifier. The first device identifier further includes M target characters, and the original device identifier further includes M target character positions. Each target character occupies one target character position, and the target characters are different from the characters in the character set. Before the above step S24 "based on the n-th random number, for the n-th character position of the original device identifier, extract a character from the character set", the method further includes step S41. The above step S25 "fill the extracted character in the n-th character position of the original device identifier to obtain the first device identifier based on the random number" specifically includes step S42:
[0103] Step S41: Fill the target characters in each of the M target character positions of the original device identifier.
[0104] In this embodiment, the target character is different from each character in the character set. For example, the target character can be a character different from those in the character set such as "-", " / ", "$", etc. The positions and quantities of the target characters in the first device identifier can be set by the manufacturer. For example, the number of target character positions is 3, which are the 1st, 3rd, and 5th positions respectively; the number of target character positions is 4, which are the 8th, 13th, 18th, and 23rd positions respectively. Assuming the target character is "-" and the number of target character positions is 4, which are the 8th, 13th, 18th, and 23rd positions respectively, then in the standard format of the device identifier corresponding to the vehicle-mounted communication terminal, the 8th / 13th / 18th / 23rd string positions of the device identifier need to be filled with "-". Assuming the target character is " / " and the number of target character positions is 3, which are the 1st, 3rd, and 5th positions respectively, then in the standard format of the device identifier corresponding to the vehicle-mounted communication terminal, the 1st, 3rd, and 5th string positions of the device identifier need to be filled with " / ".
[0105] Step S42: Fill the extracted character at the nth character position in the original device identifier except for the M target character positions to obtain the first device identifier based on the random number.
[0106] In this embodiment, the first device identifier includes M + N characters. In the process of generating the first device identifier based on the random number, after filling each of the M target character positions in the original device identifier with the M target characters, then fill the extracted nth character at the nth character position in the original device identifier except for the M target character positions to obtain the first device identifier.
[0107] In an example, M is 4 and N is 32. Then the first device identifier includes 32 characters and 4 target characters. The original device identifier includes 32 character positions and 4 target character positions, where the 4 target character positions are respectively the 8th, 13th, 18th, and 23rd character positions of the original device identifier. When the target character is "-", the "-" can be filled at the 8th, 13th, 18th, and 23rd character positions of the original device identifier first, and then the nth extracted character is filled at the nth character position among the other 32 character positions in the original device identifier except for the 8th, 13th, 18th, and 23rd character positions, so as to obtain the first device identifier.
[0108] In one embodiment, as Figure 2 shown Figure 2 is the flowchart of the step of generating the first device identifier based on the random number in the device identifier generation method proposed in an embodiment of the present application. In Figure 2In it, for the message to be sent to the second device, the specific process of generating the first device identifier based on a random number is as follows: Create a character set (such as the chars array), and create a device identifier array with a length of 36. Through loop processing, each character position of the device identifier is filled. That is, it is judged whether the end of the device identifier is reached. If the end of the device identifier is reached, the process ends; if the end of the device identifier is not reached, move to the next position of the device identifier and fill the moved character position. During the filling process, a "-" assignment operation is performed on special positions; obtain a time-based random number; randomly extract a value from 0 to 15 as the subscript of the character set (such as chars) to obtain a value (take the remainder of the time-based random number divided by 16 to get an integer in the range of 0 to 15 as the index value, and extract the corresponding character from chars according to the index value, such as index value index = 15 → chars
[15] = "f'"); assign the obtained value to the device identifier. When the loop processing ends, it means that all positions of the device identifier have been processed, and the first device identifier based on the random number is obtained.
[0109] In an implementation manner, the present application further provides a method for generating a device identifier. In this method, the first device identifier further includes M target characters. The above step S12 "According to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, adjust the characters in the first device identifier to obtain a target device identifier" may specifically include the following step S51:
[0110] Step S51: According to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, adjust multiple characters in the first device identifier except the M target characters to obtain a target device identifier.
[0111] In this embodiment, the M target characters in the first device identifier can be kept unchanged, and according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, multiple characters in the first device identifier except the M target characters are adjusted to obtain a target device identifier.
[0112] In an optional example, when the first device is a vehicle-mounted communication terminal and is adjusted to be replaced, for the first device identifier generated for the first device, the first device identifier is generally represented as a string with a length of 36 characters, where there are M target characters at special character positions, such as there are target characters '-' at 4 target character positions respectively. Therefore, when replacing the characters in the first device identifier according to the hardware attribute information and / or message attribute information corresponding to the first device, it is to replace multiple characters in the first device identifier except these 4 target characters '-', so as to obtain the target device identifier. For example, according to the hardware attribute information corresponding to the first device, determine the corresponding string and the number of characters a of the string, and replace the first a characters (except the target character '-') in the first device identifier with the string corresponding to the hardware attribute information; and / or, according to the message attribute information corresponding to the first device, determine the corresponding string and the number of characters b of the string, and replace the last b characters (except the target character '-') in the first device identifier with the string corresponding to the message attribute information, and finally obtain the target device identifier.
[0113] In an implementation manner, the present application further provides a method for generating a device identifier. In this method, the above step S12 "adjust the characters in the first device identifier according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the to-be-sent message to obtain a target device identifier" may specifically include the following steps S61 to S62:
[0114] Step S61: Determine a first string representing the hardware attribute information; and / or, obtain the message number corresponding to the to-be-sent message, and determine a second string representing the message number; the message number increases as the total number of messages sent from the first device to the second device increases.
[0115] In this embodiment, read the vehicle identification number (VIN) stored in the vehicle-mounted communication terminal. The VIN is a 17-bit character sequence that contains vehicle manufacturing information, year, model, etc. Convert the VIN into a format suitable for character replacement in the device identifier, such as a hexadecimal string, to obtain a first string representing the hardware attribute information of the vehicle-mounted communication terminal. And, obtain the msgID corresponding to the message to be sent to the server from the vehicle-mounted communication terminal, and determine a second string representing the message number (msgID). The msgID is used to identify each sent message and increments each time a message is sent, that is, it increases as the total number of messages sent from the vehicle-mounted communication terminal to the server increases, so as to ensure that the messages sent by each device are different.
[0116] Step S62: Adjust multiple first characters in the first device identifier by using the first string, and / or adjust multiple second characters in the first device identifier by using the second string, to obtain a target device identifier, where the character positions of the multiple first characters do not overlap with the character positions of the multiple second characters.
[0117] In this embodiment, multiple first characters in the first device identifier are adjusted by using the first string obtained in step S61. For example, if the VIN number of a certain vehicle model is a random combination of 17 letters and numbers, then the 17 characters of the VIN number are replaced with the first 17 characters of the first device identifier (excluding the target character "-"). And / or multiple second characters in the first device identifier are adjusted by using the second string obtained in step S61. For example, the last 8 positions of the first device identifier are filled byte by byte with a variable msgID of uint64 type. Among them, the character positions of the multiple first characters do not overlap with the character positions of the multiple second characters. After character replacement, a target device identifier is obtained.
[0118] In one implementation manner, the present application further provides a method for generating a device identifier. In this method, the above step S12 "Adjust the characters in the first device identifier according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, to obtain a target device identifier" may specifically include the following steps:
[0119] Determine a third string according to the hardware attribute information of the hardware components deployed in the first device and the message attribute information of the message to be sent, and adjust multiple characters in the first device identifier by using the third string to obtain a target device identifier.
[0120] For example, when the hardware attribute information is a car machine terminal identifier and the message attribute information is a message type identifier, if the car machine terminal identifier is a 14-bit string and the message type identifier is a 6-bit string, the car machine terminal identifier and the message type identifier can be combined arbitrarily (such as directly splicing in the original string order, or randomly combining by scrambling the characters in the two strings), to obtain a 20-bit third string, and then use this 20-bit third string to replace the first / middle / last 20 characters (except the target character) in the first device identifier to obtain a target device identifier.
[0121] In one implementation manner, the present application further provides a method for generating a device identifier. After obtaining the target device identifier in the above step S12, this method may further include the following steps S71 to S74:
[0122] Step S71: Obtain the hardware utilization rate of the first device, where the hardware utilization rate includes at least one of the following: CPU utilization rate, memory utilization rate;
[0123] Step S72: When the hardware utilization rate is less than the first threshold, encrypt the target device identifier using the first encryption method;
[0124] Step S73: When the hardware utilization rate is greater than or equal to the first threshold and less than the second threshold, encrypt the target device identifier using the second encryption method, where the hardware resource consumption of the second encryption method is lower than that of the first encryption method, and the second threshold is greater than the first threshold;
[0125] Step S74: When the hardware utilization rate is greater than or equal to the second threshold, determine not to encrypt the target device identifier using any encryption method.
[0126] In this embodiment, the encryption algorithms include RC4 (Rivest Cipher 4), ChaCha20 (ChaCha with 20 rounds), Blowfish, AES-128 (Advanced Encryption Standard with 128-bit key), 3DES (Triple Data Encryption Standard), Serpent, etc. The above algorithms are sorted in ascending order of hardware resource consumption. Considering that the first device is a vehicle-mounted communication terminal, it will consume a large amount of system resources during remote control, intensive data packet reporting, or OTA. Based on these resource-intensive scenarios, according to the real-time obtained hardware utilization rate of the first device (such as obtaining the CPU utilization rate alone, obtaining the memory utilization rate alone, or obtaining both the CPU utilization rate and the memory utilization rate simultaneously), select an appropriate encryption algorithm according to the defined priority to ensure data security while reducing the impact on system resources. Specifically, two thresholds are preset in advance to determine the logic of switching different encryption algorithms:
[0127] When the hardware utilization rate is less than the first threshold, encrypt the target device identifier using the first encryption method. For example, when obtaining the CPU utilization rate alone as the hardware utilization rate, read the current CPU utilization rate through the API provided by the operating system. When the CPU utilization rate < 40%, encrypt the target device identifier using AES-128 to balance security and performance.
[0128] When the hardware utilization rate is greater than or equal to the first threshold and less than the second threshold, the second encryption method is used to encrypt the target device identifier. The hardware resource consumption of the second encryption method is lower than that of the first encryption method. The first threshold represents the utilization rate when the hardware resources are relatively abundant, and the second threshold represents the utilization rate when the hardware resources start to become tense. The second threshold is greater than the first threshold. For example, when 40% ≤ CPU utilization rate < 60%, a relatively lightweight algorithm such as RC4 is used to encrypt the target device identifier to ensure the normal operation of the system. Specifically, the hardware resource consumption of the second encryption method is lower than that of the first encryption method. For example, when the first encryption method selects AES-128, the second encryption method can select RC4, ChaCha2, or Blowfish with lower hardware resource consumption than AES-128. When the first encryption method selects Serpent, the second encryption method can select RC4, ChaCha20, Blowfish, AES-128, or 3DES with lower hardware resource consumption than Serpent.
[0129] When the hardware utilization rate is greater than or equal to the second threshold, it is determined not to use any encryption method to encrypt the target device identifier. For example, when the CPU utilization rate ≥ 60%, a restriction is executed, and the target device identifier is not encrypted, and only critical data (important messages) are encrypted.
[0130] In one embodiment, as Figure 3 shown, Figure 3 is a schematic diagram of the comprehensive CPU utilization rate and encryption algorithm of the device identifier generation method proposed in an embodiment of the present application. In Figure 3 , a field is opened in the message payload to indicate whether an encryption algorithm is currently used. If an encryption algorithm is used, the encryption method is described. Specifically, when the central processing unit utilization rate (CPU utilization rate) < 40%, the Advanced Encryption Standard (128-bit key) (i.e., AES-128) is used to encrypt the target device identifier; when 40% ≤ central processing unit utilization rate (CPU utilization rate) < 60%, the relatively lightweight algorithm Rivest Cipher 4 (RC4) is used to encrypt the target device identifier; when the central processing unit utilization rate (CPU utilization rate) ≥ 60%, a restriction is executed, and the target device identifier is not encrypted; finally, the message payload (i.e., the message payload) is obtained: encryption method + device identifier content.
[0131] Taking into account the low-power characteristics of embedded devices, the stability requirements of automotive parts for products, and security considerations, this application proposes an optimized superimposed algorithm based on the above target device identifier algorithm. According to the CPU usage rate obtained in real time, a suitable encryption algorithm is selected according to the defined priority to encrypt the target device identifier. Through the dynamic encryption algorithm selection mechanism based on the CPU usage rate, power consumption and system performance can be optimized while ensuring data security, preventing performance bottlenecks when the device is overloaded, and can be used in embedded devices or resource-constrained environments.
[0132] In one implementation, this application also provides a method for generating a device identifier, and this method may further include the following steps S81 to S83:
[0133] Step S81: Generate an encryption prompt message according to whether to encrypt the target device identifier and the encryption method used when encrypting the target device identifier;
[0134] Step S82: Generate a target message according to the encryption prompt message, the target device identifier, and the message content of the message to be sent;
[0135] Step S83: Send the target message to the second device.
[0136] In this embodiment, an encryption prompt message is generated according to whether to encrypt the target device identifier and the encryption method used. For example, a flag bit can be used to indicate whether to encrypt, and another field can be used to indicate the encryption method. Combine the target device identifier, the encryption prompt message, and the message content into a complete target message and send it to the second device. Through the encryption prompt message, the receiving party can know whether the message is encrypted and the encryption method used to ensure that both parties can correctly parse and process the message.
[0137] In one implementation, this application also provides a method for generating a device identifier, and this method further includes step S91. The above step S11, "For the message to be sent to the second device, generate a first device identifier based on a random number", specifically further includes step S92:
[0138] Step S91: Determine the message type of the message to be sent;
[0139] Step S92: When the message type belongs to the target message type, generate a first device identifier based on a random number for the message to be sent, and the target message type includes any one of the following: login message type, logout message type, sleep message type, wake-up message type, remote control response message type, reservation vehicle control message type, OTA upgrade message type.
[0140] In this embodiment, the message type of the message to be sent can be determined by parsing the message content or checking the type field in the message header. The target message types include any one of the following: login message type, logout message type, sleep message type, wake-up message type, remote control response message type, reserved vehicle control message type, and OTA upgrade message type. If the message type belongs to the target message type, a first device identifier based on a random number is generated for the message to be sent. This is to facilitate targeted processing of specific types of messages.
[0141] Based on the same inventive concept, an embodiment of the present disclosure further provides a vehicle, including: a memory storing the vehicle identification number of the vehicle; an in-vehicle terminal configured to use the vehicle identification number as the hardware attribute information of the hardware components deployed inside the first device, and execute the steps in the device identifier generation method described in any one of the above embodiments of the present application.
[0142] Based on the same inventive concept, an embodiment of the present application provides a device identifier generation device applied to a first device. Figure 4 It is a schematic structural diagram of the device identifier generation device proposed in an embodiment of the present application, as Figure 4 shown, the device identifier generation device includes:
[0143] A first processing module configured to generate a first device identifier based on a random number for a message to be sent to a second device;
[0144] A second processing module configured to adjust the characters in the first device identifier according to the hardware attribute information of the hardware components deployed inside the first device and / or the message attribute information of the message to be sent, to obtain a target device identifier, where the target device identifier is used to indicate to the second device that the message to be sent comes from the first device.
[0145] In an optional implementation manner, the first device identifier includes at least N characters, and each character occupies one character position; the first processing module includes:
[0146] An initialization module configured to initialize an original device identifier including at least N character positions, where the characters at each character position of the original device identifier are initial characters;
[0147] A first acquisition module configured to acquire the timestamp corresponding to the message to be sent, where the timestamp represents the generation moment of the message content of the message to be sent or the sending moment of the message to be sent;
[0148] A random number generation module configured to generate N random numbers based on the timestamp;
[0149] An extraction module, configured to extract a character from a character set for the nth character position of the original device identifier based on the nth random number, where the character set includes a plurality of different characters, and n ranges from 1 to N;
[0150] A first filling module, configured to fill the extracted character at the nth character position of the original device identifier to obtain a first device identifier based on the random number.
[0151] In an optional implementation manner, the extraction module includes:
[0152] A first determination module, configured to determine an index value of the nth character position of the original device identifier based on the nth random number and the total number of characters in the character set;
[0153] An index module, configured to extract a character corresponding to the index value of the nth character position of the original device identifier from the character set, where different characters in the character set correspond to different index values.
[0154] In an optional implementation manner, the first device identifier further includes M target characters, and the original device identifier further includes M target character positions. Each target character occupies one target character position, and the target characters are different from the characters in the character set; the apparatus further includes:
[0155] A second filling module, configured to fill the target characters at each of the M target character positions of the original device identifier before extracting a character from the character set for the nth character position of the original device identifier based on the nth random number;
[0156] The first filling module includes:
[0157] A first filling sub-module, configured to fill the extracted character at the nth character position of the original device identifier except for the M target character positions to obtain a first device identifier based on the random number.
[0158] In an optional implementation manner, the first device identifier further includes M target characters, and the second processing module includes:
[0159] A first replacement module, configured to adjust a plurality of characters in the first device identifier except for the M target characters according to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent to obtain a target device identifier.
[0160] In an optional implementation manner, the second processing module includes:
[0161] A second determination module, configured to determine a first string representing the hardware attribute information; and / or, obtain a message number corresponding to the message to be sent, and determine a second string representing the message number; the message number increases as the total number of messages sent from the first device to the second device increases;
[0162] A second replacement module, configured to use the first string to adjust multiple first characters in the first device identifier, and / or use the second string to adjust multiple second characters in the first device identifier, to obtain a target device identifier, where the character positions of the multiple first characters do not overlap with the character positions of the multiple second characters.
[0163] In an optional implementation manner, the apparatus further includes:
[0164] A second acquisition module, configured to acquire the hardware utilization rate of the first device, where the hardware utilization rate includes at least one of the following: CPU utilization rate, memory utilization rate;
[0165] A first encryption module, configured to, when the hardware utilization rate is less than a first threshold, encrypt the target device identifier using a first encryption method;
[0166] A second encryption module, configured to, when the hardware utilization rate is greater than or equal to the first threshold and less than a second threshold, encrypt the target device identifier using a second encryption method, where the hardware resource consumption of the second encryption method is lower than that of the first encryption method, and the second threshold is greater than the first threshold;
[0167] A third encryption module, configured to, when the hardware utilization rate is greater than or equal to the second threshold, determine not to encrypt the target device identifier using any encryption method.
[0168] In an optional implementation manner, the apparatus further includes:
[0169] A prompt information generation module, configured to generate encryption prompt information according to whether the target device identifier is encrypted and the encryption method used when encrypting the target device identifier;
[0170] A target information generation module, configured to generate a target message according to the encryption prompt information, the target device identifier, and the message content of the message to be sent;
[0171] A sending module, configured to send the target message to the second device.
[0172] In an optional implementation manner, the apparatus further includes:
[0173] A third determination module, configured to determine the message type of the message to be sent;
[0174] The first processing module includes:
[0175] A first identifier generation module, configured to generate a first device identifier based on a random number for the message to be sent when the message type belongs to a target message type, where the target message type includes any one of the following: a login message type, a logout message type, a sleep message type, a wake-up message type, a remote control response message type, a reserved vehicle control message type, an OTA upgrade message type.
[0176] Based on the same inventive concept, an embodiment of the present application provides an electronic device. Refer to Figure 5 , Figure 5 is a schematic diagram of an electronic device proposed in an embodiment of the present application. As Figure 5 shown, the electronic device 100 includes: a memory 110 and a processor 120. The memory 110 is communicatively connected to the processor 120 through a bus. A computer program is stored in the memory 110, and the computer program can run on the processor 120, thereby implementing the steps in the device identifier generation method described in any of the above embodiments of the present application.
[0177] Based on the same inventive concept, an embodiment of the present disclosure also provides a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of a computer device, the computer device can execute the steps in the device identifier generation method described in any of the above embodiments of the present application.
[0178] Based on the same inventive concept, an embodiment of the present disclosure also provides a computer program product, including a computer program. When the computer program is executed by a processor of a computer device, it can execute the steps in the device identifier generation method described in any of the above embodiments of the present application.
[0179] Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other.
[0180] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, an apparatus, or a computer program product. Therefore, the embodiments of the present application can take the form of an all-hardware embodiment, an all-software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0181] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.
[0182] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal devices to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.
[0183] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal devices, such that a series of operation steps are executed on the computer or other programmable terminal devices to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable terminal devices provide steps for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.
[0184] Although the preferred embodiments of the embodiments of the present application have been described, those skilled in the art can make additional changes and modifications once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0185] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, article or terminal device comprising the said element.
[0186] The above has introduced in detail a method for generating a device identifier and a vehicle provided by the present application. Specific examples are used in this text to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for generating a device identifier, characterized in that, Applied to a first device, the method includes: Generating a first device identifier based on a random number for a message to be sent to a second device; Adjusting characters in the first device identifier according to hardware attribute information of hardware components deployed within the first device and / or message attribute information of the message to be sent, to obtain a target device identifier, including: Determining a first string characterizing the hardware attribute information; and / or, obtaining a message number corresponding to the message to be sent and determining a second string characterizing the message number; the message number increases as the total number of messages sent from the first device to the second device increases; Adjusting multiple first characters in the first device identifier using the first string, and / or adjusting multiple second characters in the first device identifier using the second string, to obtain a target device identifier, where the character positions of the multiple first characters do not overlap with the character positions of the multiple second characters; Wherein, the target device identifier is used to indicate to the second device that the message to be sent comes from the first device.
2. The method for generating a device identifier according to claim 1, wherein, The first device identifier includes at least N characters, and each character occupies one character position; Generating a first device identifier based on a random number for a message to be sent to a second device, including: Initializing a raw device identifier including at least N character positions, where the characters at each character position of the raw device identifier are initial characters; Obtaining a timestamp corresponding to the message to be sent, the timestamp characterizing the generation moment of the message content of the message to be sent or the sending moment of the message to be sent; Generating N random numbers based on the timestamp; Based on the nth random number, extracting a character from a character set for the nth character position of the raw device identifier, the character set including multiple different characters, and n ranges from 1 to N; Filling the extracted character in the nth character position of the raw device identifier to obtain a first device identifier based on a random number.
3. The method for generating a device identifier according to claim 2, wherein Based on the nth random number, extracting a character from a character set for the nth character position of the raw device identifier, including: Determining an index value of the nth character position of the raw device identifier based on the nth random number and the total number of characters in the character set; Extracting a character corresponding to the index value of the nth character position of the raw device identifier from the character set, where different characters in the character set correspond to different index values.
4. The method for generating a device identifier according to claim 2, wherein, The first device identifier further includes M target characters, and the raw device identifier further includes M target character positions, each target character occupying one target character position, and the target characters are different from each of the characters in the character set; Before extracting a character from a character set for the nth character position of the raw device identifier based on the nth random number, the method further includes: Filling the target characters in each of the M target character positions of the raw device identifier; Filling the extracted characters at the n-th character position of the original device identifier to obtain a first device identifier based on a random number, including: Filling the extracted characters at the n-th character position of the original device identifier except for the M target character positions to obtain a first device identifier based on a random number.
5. The method for generating a device identifier according to claim 2, characterized in that, The first device identifier further includes M target characters. According to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, adjusting the characters in the first device identifier to obtain a target device identifier, including: According to the hardware attribute information of the hardware components deployed in the first device and / or the message attribute information of the message to be sent, adjusting a plurality of characters in the first device identifier except for the M target characters to obtain a target device identifier.
6. The method for generating a device identifier according to any one of claims 1-5, characterized in that, After obtaining the target device identifier, the method further includes: Obtaining the hardware utilization rate of the first device, where the hardware utilization rate includes at least one of the following: CPU utilization rate, memory utilization rate; When the hardware utilization rate is less than a first threshold, encrypting the target device identifier using a first encryption method; When the hardware utilization rate is greater than or equal to the first threshold and less than a second threshold, encrypting the target device identifier using a second encryption method, where the hardware resource consumption of the second encryption method is lower than that of the first encryption method, and the second threshold is greater than the first threshold; When the hardware utilization rate is greater than or equal to the second threshold, determining not to encrypt the target device identifier using any encryption method.
7. The method for generating a device identifier according to claim 6, wherein, The method further includes: Generating an encryption prompt information according to whether the target device identifier is encrypted and the encryption method used when encrypting the target device identifier; Generating a target message according to the encryption prompt information, the target device identifier, and the message content of the message to be sent; Sending the target message to the second device.
8. The method for generating a device identifier according to claim 7, wherein The method further includes: Determining the message type of the message to be sent; Generating a first device identifier based on a random number for the message to be sent to the second device, including: When the message type belongs to a target message type, generating a first device identifier based on a random number for the message to be sent, where the target message type includes any one of the following: login message type, logout message type, sleep message type, wake-up message type, remote control response message type, reserved vehicle control message type, OTA upgrade message type.
9. A vehicle, characterized in that, Including: A memory storing the vehicle identification number of the vehicle; An in-vehicle terminal for using the vehicle identification number of the vehicle as the hardware attribute information of the hardware components deployed in the first device and performing the steps of implementing the device identifier generation method according to any one of claims 1-8.
Citation Information
Patent Citations
Vehicle identification number VIN coding and verification method, device, equipment and medium
CN117494170A
Identification generation method and device, computer equipment, storage medium and program product
CN118036045A