CN114626338A - Character encoding method, character decoding method, character encoding system, character decoding system, character encoding device, character decoding device, and storage medium - Google Patents
Character encoding method, character decoding method, character encoding system, character decoding system, character encoding device, character decoding device, and storage medium Download PDFInfo
- Publication number
- CN114626338A CN114626338A CN202210193676.1A CN202210193676A CN114626338A CN 114626338 A CN114626338 A CN 114626338A CN 202210193676 A CN202210193676 A CN 202210193676A CN 114626338 A CN114626338 A CN 114626338A
- Authority
- CN
- China
- Prior art keywords
- numerical value
- data
- character
- value
- encoding
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 claims abstract description 65
- 238000004590 computer program Methods 0.000 claims description 10
- 238000004891 communication Methods 0.000 claims description 9
- 238000004422 calculation algorithm Methods 0.000 abstract description 6
- 238000004364 calculation method Methods 0.000 description 6
- 238000013507 mapping Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 229910002056 binary alloy Inorganic materials 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 238000012795 verification Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/12—Use of codes for handling textual entities
- G06F40/126—Character encoding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computer Hardware Design (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- Bioethics (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- Document Processing Apparatus (AREA)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
Abstract
本申请涉及一种数据的字符编码、解码方法、系统、设备及存储介质;其中,所述编码方法包括:获取发送端上传的待编码的数据;调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。本申请用以解决现有技术中,利用对称或非对称加密的算法比较繁琐的技术问题。
The present application relates to a character encoding and decoding method, system, device and storage medium for data; wherein, the encoding method includes: acquiring the data to be encoded uploaded by the sender; calling the smart contract of the blockchain system to convert the The data is converted into a first numerical value of the first base; the first numerical value is encoded by using a threshold value pre-agreed with the receiving end, and the second numerical value of the first base corresponding to the data is obtained; according to the preset A character encoding table, for determining a character encoding result corresponding to the second numerical value. The present application is used to solve the technical problem in the prior art that the algorithm using symmetric or asymmetric encryption is cumbersome.
Description
技术领域technical field
本申请涉及区块链技术领域,尤其涉及一种数据的字符编码、解码方法、系统、设备及存储介质。The present application relates to the technical field of blockchain, and in particular, to a method, system, device and storage medium for character encoding and decoding of data.
背景技术Background technique
目前,大部分敏感数据加密场景的解决方案都是通过对称或非对称加密来进行,在端到端的业务流程中,保证中间人可见不可读,上述传统方案适用于绝大部分场景。At present, most of the solutions for sensitive data encryption scenarios are carried out through symmetric or asymmetric encryption. In the end-to-end business process, the middleman is guaranteed to be visible and unreadable. The above traditional solutions are suitable for most scenarios.
但是,对于发送端,需要预先配置加密算法,在发送敏感数据时,调用加密算法,利用加密算法对待发送的敏感数据进行加密,算法比较繁琐,计算量大,使得方案比较笨重。However, for the sender, the encryption algorithm needs to be pre-configured. When sending sensitive data, the encryption algorithm is called, and the encryption algorithm is used to encrypt the sensitive data to be sent.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种数据的字符编码、解码方法、系统、设备及存储介质,用以解决现有技术中,利用对称或非对称加密的算法比较繁琐的技术问题。The present application provides a character encoding and decoding method, system, device and storage medium for data, which are used to solve the technical problem that the symmetric or asymmetric encryption algorithm is relatively cumbersome in the prior art.
第一方面,本申请实施例提供了一种数据的字符编码方法,适用于区块链系统,所述方法包括:In the first aspect, the embodiments of the present application provide a data character encoding method, which is applicable to a blockchain system, and the method includes:
获取发送端上传的待编码的数据;Obtain the data to be encoded uploaded by the sender;
调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。Invoke the smart contract of the blockchain system to convert the data into the first numerical value of the first system; encode the first numerical value with the threshold pre-agreed with the receiving end, and obtain the first numerical value corresponding to the data The second numerical value in a hexadecimal system; according to the preset character encoding table, determine the character encoding result corresponding to the second numerical value.
可选的,所述利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值,包括:Optionally, encoding the first numerical value by using a threshold pre-agreed with the receiving end to obtain the second numerical value of the first system corresponding to the data, including:
调用所述智能合约将所述阈值转换为第一进制,得到第一进制的阈值,并计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值。Invoke the smart contract to convert the threshold into the first base, obtain the threshold of the first base, and calculate the sum of the first value and the threshold of the first base to obtain the first value corresponding to the data. The second value in unary.
可选的,所述根据预设的字符编码表,确定与所述第二数值对应的字符编码结果,包括:Optionally, the character encoding result corresponding to the second numerical value is determined according to the preset character encoding table, including:
调用所述智能合约,将所述第二数值转换为第二进制的第三数值;calling the smart contract to convert the second value into the third value of the second binary;
从所述字符编码表中,读取与所述第三数值对应的字符编码结果。From the character encoding table, read the character encoding result corresponding to the third numerical value.
可选的,所述区块链系统中存储有所述发送端和所述接收端最后一次会话记录;所述利用与接收端预先约定的阈值对所述第一数值进行编码之前,还包括:Optionally, the last session record of the sender and the receiver is stored in the blockchain system; before encoding the first numerical value with a threshold pre-agreed with the receiver, the method further includes:
调用所述智能合约,获取所述发送端和所述接收端最后一次会话记录对应的会话标识号;Invoke the smart contract to obtain the session identification number corresponding to the last session record of the sender and the receiver;
根据所述会话标识号确定与所述接收端预先约定的阈值。A threshold pre-agreed with the receiving end is determined according to the session identification number.
可选的,所述根据所述会话标识号确定与所述接收端预先约定的阈值,包括:Optionally, determining the threshold pre-agreed with the receiving end according to the session identification number, including:
从所述会话标识号中,读取至少一位目标数据,将所述至少一位目标数据作为与所述接收端预先约定的阈值。From the session identification number, at least one bit of target data is read, and the at least one bit of target data is used as a threshold value pre-agreed with the receiving end.
第二方面,本申请实施例提供了一种数据的字符解码方法,适用于接收端,所述方法包括:In the second aspect, an embodiment of the present application provides a data character decoding method, which is applicable to a receiving end, and the method includes:
根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;According to the preset character encoding table, determine the second numerical value of the first system corresponding to the character encoding result;
利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;Decode the second numerical value by using the threshold value pre-agreed with the sender to obtain the first numerical value of the first system;
基于所述第一数值确定解码结果。A decoding result is determined based on the first value.
可选的,所述利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值,包括:Optionally, the second numerical value is decoded by using the threshold pre-agreed with the sender to obtain the first numerical value in the first system, including:
将所述阈值转换为第一进制,得到第一进制的阈值;Converting the threshold into the first system to obtain the threshold of the first system;
计算所述第二数值和所述第一进制的阈值的差值,得到所述第一进制的第一数值。Calculate the difference between the second numerical value and the threshold value of the first base to obtain the first numerical value of the first base.
第三方面,本申请实施例提供了一种数据的字符编解码系统,包括:区块链系统和接收端;In a third aspect, the embodiments of the present application provide a character encoding and decoding system for data, including: a blockchain system and a receiving end;
所述区块链系统,用于获取发送端上传的待编码的数据;调用所述区块链系统的智能合约将所述数据转换为第一进制的第一数值;利用与目标接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果;向所述接收端发送所述字符编码结果;The blockchain system is used to obtain the data to be encoded uploaded by the sender; call the smart contract of the blockchain system to convert the data into the first numerical value of the first system; Encoding the first numerical value with the agreed threshold to obtain the second numerical value of the first system corresponding to the data; determining the character encoding result corresponding to the second numerical value according to the preset character encoding table; The receiving end sends the character encoding result;
所述接收端,用于根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;基于所述第一数值确定解码结果。The receiving end is used to determine, according to a preset character encoding table, the second numerical value of the first hexadecimal corresponding to the character encoding result; decode the second numerical value by using the threshold pre-agreed with the transmitting end to obtain The first numerical value of the first base; the decoding result is determined based on the first numerical value.
第四方面,本申请实施例提供了一种电子设备,包括:处理器、存储器和通信总线,其中,处理器和存储器通过通信总线完成相互间的通信;In a fourth aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory, and a communication bus, wherein the processor and the memory communicate with each other through the communication bus;
所述存储器,用于存储计算机程序;the memory for storing computer programs;
所述处理器,用于执行所述存储器中所存储的程序,实现第一方面所述的数据的字符编码方法或第二方面所述的数据的字符解码方法。The processor is configured to execute the program stored in the memory to implement the character encoding method for data described in the first aspect or the character decoding method for data described in the second aspect.
第五方面,本申请实施例提供了一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现第一方面所述的数据的字符编码方法或第二方面所述的数据的字符解码方法。In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the method for character encoding of the data described in the first aspect or the method described in the second aspect is implemented. The character decoding method of the data.
本申请实施例提供的上述技术方案与现有技术相比具有如下优点:本申请实施例提供的该方法,利用发送端和接收端预先约定的阈值对待编码的数据的第一数值进行编码,得到第二数值,之后根据字符编码表,确定第二数值对应的字符编码结果,利用字符编码的思想,对数据进行编码,步骤简单,且在编码过程中,计算量小。而且,上述过程均在区块链系统的智能合约中完成,通过智能合约记录上述操作的全程生命周期,便于后续查证。Compared with the prior art, the above technical solutions provided by the embodiments of the present application have the following advantages: the method provided by the embodiments of the present application encodes the first value of the data to be encoded by using the threshold value pre-agreed by the transmitting end and the receiving end to obtain The second numerical value is then determined according to the character coding table, and the character coding result corresponding to the second numerical value is determined, and the data is coded using the idea of character coding. The steps are simple, and the calculation amount is small in the coding process. Moreover, the above process is completed in the smart contract of the blockchain system, and the whole life cycle of the above operation is recorded through the smart contract, which is convenient for subsequent verification.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本发明的实施例,并与说明书一起用于解释本发明的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description serve to explain the principles of the invention.
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. In other words, on the premise of no creative labor, other drawings can also be obtained from these drawings.
图1为本申请实施例提供的一种数据的字符编码方法的流程示意图;1 is a schematic flowchart of a data character encoding method according to an embodiment of the present application;
图2为本申请实施例提供的一种数据的字符解码方法的流程示意图;2 is a schematic flowchart of a data character decoding method provided by an embodiment of the present application;
图3为本申请实施例提供的一种数据的字符编解码系统的结构示意图;3 is a schematic structural diagram of a data character encoding and decoding system according to an embodiment of the present application;
图4为本申请实施例提供的一种数据的字符编码装置的结构示意图;4 is a schematic structural diagram of a data character encoding device according to an embodiment of the present application;
图5为本申请实施例提供的一种数据的字符解码装置的结构示意图;5 is a schematic structural diagram of a data character decoding apparatus provided by an embodiment of the present application;
图6为本申请实施例提供的一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
具体实施方式Detailed ways
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments It is a part of the embodiments of this application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present application.
为了解决现有技术中,利用对称或非对称加密的算法比较繁琐的技术问题,本申请实施例提供了一种数据的字符编码方法,如图1所示,本申请实施例提供的一种数据的字符编码方法,适用于区块链系统,该数据的字符编码方法具体包括如下步骤:In order to solve the technical problem that the use of symmetric or asymmetric encryption algorithms is cumbersome in the prior art, an embodiment of the present application provides a data character encoding method. As shown in FIG. 1 , a data character encoding method provided by an embodiment of the present application The character encoding method of the data is suitable for the blockchain system. The character encoding method of the data specifically includes the following steps:
步骤101,获取发送端上传的待编码的数据;
其中,数据可以是敏感数据,例如:用户的手机号、身份证号、家庭住址等隐私数据;还可以是其他数据,例如:发送端向接收端发送的会话内容等。The data can be sensitive data, such as the user's mobile phone number, ID number, home address and other private data; it can also be other data, such as the session content sent by the sender to the receiver.
步骤102,调用所述区块链系统的智能合约将所述数据转换为第一进制的第一数值;
为了数据能够在计算机中存储以及通过通信网络传输,需要将字符集中的字符编码为指定集合中的某一个对象,例如:比特模式、自然数序列、8位组或者电脉冲等等。常见的例子包括:将拉丁字母表编码成摩斯电码和ASCII。其中,ASCII将字母、数字和其它符号编号,并用7比特的二进制来表示这个整数。通常会额外使用一个扩充的比特,共8比特,以便于以1个字节的方式存储。In order for data to be stored in a computer and transmitted through a communication network, the characters in the character set need to be encoded as an object in a specified set, such as a bit pattern, a sequence of natural numbers, an 8-bit group, or an electrical pulse. Common examples include: encoding the Latin alphabet into Morse code and ASCII. Among them, ASCII numbers letters, numbers, and other symbols, and uses 7-bit binary to represent this integer. Usually an extra bit of extension is used, totaling 8 bits, so that it can be stored in 1 byte.
在具体实现时,第一进制可以是二进制,将待编码的数据转换为二进制的第一数值。During specific implementation, the first digit may be binary, and the data to be encoded is converted into the first binary value.
步骤103,利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;
其中,与接收端预先约定的阈值需要全局唯一,以防止其他接收到字符编码结果的客户端解读出来。Among them, the threshold value pre-agreed with the receiving end needs to be globally unique to prevent other clients receiving the character encoding result from interpreting it.
在一个具体实施例中,所述区块链系统中存储有所述发送端和所述接收端最后一次会话记录;所述利用与接收端预先约定的阈值对所述第一数值进行编码之前,还包括:In a specific embodiment, the last session record of the sender and the receiver is stored in the blockchain system; before the first value is encoded by the threshold pre-agreed with the receiver, Also includes:
调用所述智能合约,获取所述发送端和所述接收端最后一次会话记录对应的会话标识号;Invoke the smart contract to obtain the session identification number corresponding to the last session record of the sender and the receiver;
根据所述会话标识号确定与所述接收端预先约定的阈值。A threshold pre-agreed with the receiving end is determined according to the session identification number.
每个会话的会话标识号具有全局唯一性,因此,通过会话标识号确定发送端和接收端约定的阈值可以保证阈值的全局唯一性,能够防止其他客户端收到信息后解读出来。同时,随着时间的推移,发送端和接收端之间最后一次会话是不断变化的,并不是固定的,避免长时间用同一个阈值,被有心之人模仿到,进一步保证了利用阈值进行编解码的安全性。The session identification number of each session is globally unique. Therefore, determining the threshold agreed by the sender and the receiver through the session identification number can ensure the global uniqueness of the threshold and prevent other clients from interpreting the information after receiving it. At the same time, with the passage of time, the last session between the sender and the receiver is constantly changing, not fixed. It avoids using the same threshold for a long time and being imitated by people with intentions, which further ensures that the threshold is used for editing. Decoding security.
在具体实现时,从所述会话标识号中,读取至少一位目标数据,将所述至少一位目标数据作为与所述接收端预先约定的阈值。During specific implementation, at least one bit of target data is read from the session identification number, and the at least one bit of target data is used as a pre-agreed threshold value with the receiving end.
会话标识号通常由一串数字和字母组成,在确定阈值时,可以从会话标识号中截取其中一段作为阈值。例如:可以读取会话标识号的最后6位目标数据作为预先约定的阈值。当然,也可以是其他位数的目标数据。The session identification number is usually composed of a series of numbers and letters. When determining the threshold, a segment of the session identification number can be intercepted as the threshold. For example, the last 6 bits of target data of the session identification number can be read as a pre-agreed threshold. Of course, it can also be the target data of other bits.
在利用与接收端预先约定的阈值对第一数值进行编码时,可以调用所述智能合约将所述阈值转换为第一进制,得到第一进制的阈值,并计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值。When encoding the first value with the threshold pre-agreed with the receiving end, the smart contract can be called to convert the threshold into the first hexadecimal, obtain the threshold of the first hexadecimal, and calculate the first value and the The sum of the thresholds in the first system obtains the second value in the first system corresponding to the data.
为了便于理解,这里举例说明,以第一进制为二进制为例,“敏感数据”对应的二进制编码分别为:110010101001111、110000100011111、110010101110000、110001101101110,阈值为5,则将5转换为二进制为101;则在二进制编码的基础上加上阈值,得到的第二数值为10010101010100、110000100100100、110010101110101、110001101110011。For ease of understanding, here is an example, taking the first hexadecimal as binary as an example, the binary codes corresponding to "sensitive data" are: 110010101001111, 110000100011111, 110010101110000, 110001101101110, and the threshold is 5, then convert 5 to binary to 101; Then the threshold is added on the basis of the binary code, and the obtained second values are 10010101010100, 110000100100100, 110010101110101, and 110001101110011.
此外,除了计算第一数值和第一进制的阈值的和进行编码,得到第一进制的第二数值之外,还可以计算第一数值和第一进制的阈值的差值或者乘积或者商,得到第一进制的第二数值。当然,也可以采用其他的编码方法。只要发送端和接收端预先约定好即可。In addition, in addition to calculating the sum of the first numerical value and the threshold value of the first base for encoding to obtain the second numerical value of the first base, the difference or product of the first numerical value and the threshold value of the first base can also be calculated or Quotient to get the second value in the first base. Of course, other encoding methods can also be used. As long as the sender and receiver have agreed in advance.
在本申请实施例中,利用阈值对数据进行编码的整个过程仅涉及进制的转换和简单的加、减、乘或除计算,十分简单。但是,对于接收端,只要没有正确的阈值,则无法得到正确的解码结果,无法知晓传递的具体内容。In this embodiment of the present application, the entire process of encoding data by using the threshold value only involves conversion of the base system and simple addition, subtraction, multiplication or division calculation, which is very simple. However, for the receiving end, as long as there is no correct threshold, the correct decoding result cannot be obtained, and the specific content of the transmission cannot be known.
步骤104,根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。Step 104: Determine a character encoding result corresponding to the second numerical value according to a preset character encoding table.
其中,字符编码表(CEF,Character Encoding Form),也称为存储格式(storageformat),是将编码字符集的非负整数值(即抽象的码位)转换成有限比特长度的整型值(称为码元code units)的序列。这对于定长编码来说是个到自身的映射(null mapping),但对于变长编码来说,该映射比较复杂,把一些码位映射到一个码元,把另外一些码位映射到由多个码元组成的序列。例如,使用16比特长的存储单元保存数字信息,系统每个单元只能够直接表示从0到65535的数值,但是,如果使用多个16位单元就能够表示更大的整数。这就是CEF的作用,它可以把Unicode(统一码)从0到140万的码空间范围的每个码位映射到单个或多个在0到65,5356范围内的码值。最简单的字符编码表就是单纯地选择足够大的单位,以保证编码字符集中的所有数值能够直接编码(一个码位对应一个码值)。这对于能够用使用八比特组来表示的编码字符集(如多数传统的非CJK(中日韩越统一表意文字)的字符集编码)是合理的,对于能够使用十六比特来表示的编码字符集(如早期版本的Unicode)来说也足够合理。但是,随着编码字符集的大小增加(例如,现在的Unicode的字符集至少需要21位才能全部表示),这种直接表示法变得越来越没有效率,并且很难让现有计算机系统适应更大的码值。因此,许多使用最新版本Unicode的系统,或者将Unicode码位对应为可变长度的8位字节序列的UTF-8,或者将码位对应为可变长度的16位序列的UTF-16。Among them, the Character Encoding Form (CEF, Character Encoding Form), also known as the storage format (storage format), is to convert the non-negative integer value (ie abstract code point) of the coded character set into an integer value of limited bit length (called is a sequence of code units). This is a mapping to itself (null mapping) for fixed-length coding, but for variable-length coding, the mapping is more complicated, mapping some code bits to one symbol, and mapping other code bits to multiple A sequence of symbols. For example, using 16-bit long storage units to store digital information, each unit of the system can only directly represent values from 0 to 65535, but if multiple 16-bit units are used, larger integers can be represented. This is the role of CEF, which can map each code point in the Unicode (Unicode) code space range from 0 to 1.4 million to a single or multiple code values in the range of 0 to 65,5356. The simplest character encoding table is simply to choose a unit large enough to ensure that all values in the encoded character set can be directly encoded (one code point corresponds to one code value). This is reasonable for coded character sets that can be represented using octets (such as most traditional non-CJK (China-Japan-Korea-Vietnamese Unified Ideographic) character set codes), and for coded characters that can be represented using 16-bit Sets (like earlier versions of Unicode) are also reasonable enough. However, as the size of the coded character set increases (for example, the character set of Unicode today requires at least 21 bits to be fully represented), this direct representation becomes increasingly inefficient and difficult to adapt to existing computer systems larger code value. As a result, many systems using recent versions of Unicode either map Unicode codepoints to UTF-8 as variable-length sequences of 8-bit bytes, or to UTF-16 as variable-length sequences of 16-bit bytes.
在具体实现时,调用所述智能合约,将所述第二数值转换为第二进制的第三数值;从所述字符编码表中,读取与所述第三数值对应的字符编码结果。其中,第二进制可以为十进制。During specific implementation, the smart contract is called to convert the second numerical value into a third numerical value of the second binary; from the character encoding table, the character encoding result corresponding to the third numerical value is read. Wherein, the second binary can be in decimal.
为了便于理解,这里继续举例说明,以第二进制为十进制为例,在步骤103的举例中,第二数值为10010101010100、110000100100100、110010101110101、110001101110011,根据步骤104的描述,将上述第二数值转换为十进制,得到第三数值为25940、24868、25973、25459。若字符编码表为UTF-8,查表确定每个数字对应的内容,则最终的字符编码结果为“UTF-8 25940|24868|25973|25459”对应的内容。In order to facilitate understanding, continue to illustrate here, taking the second binary number as decimal as an example, in the example of
上述得到的字符串,即作为数据编码之后的结果,对于某些阈值不可见的客户端,数据不可读。但对于阈值可见的客户端,可以人为或系统反加工得到具体内容,计算量小,十分方便。而且,本身在数据传输的过程中也需要将数据转换为二进制,本申请实施例顺势而为,步骤简单,计算量小,十分灵活。The string obtained above, that is, as a result of data encoding, is unreadable for some clients whose thresholds are not visible. However, for clients with visible thresholds, the specific content can be obtained by human or system reverse processing, and the calculation amount is small, which is very convenient. Moreover, the data itself needs to be converted into binary in the process of data transmission, and the embodiment of the present application follows the trend, the steps are simple, the calculation amount is small, and it is very flexible.
在本申请实施例中,利用发送端和接收端预先约定的阈值对待编码的数据的第一数值进行编码,得到第二数值,之后根据字符编码表,确定第二数值对应的字符编码结果,利用字符编码的思想,对数据进行编码,步骤简单,且在编码过程中,计算量小。此外,上述过程均在区块链系统的智能合约中完成,通过智能合约记录上述操作的全程生命周期,便于后续查证。In the embodiment of the present application, the first value of the data to be encoded is encoded by using the threshold value pre-agreed by the sending end and the receiving end to obtain the second value, and then the character encoding result corresponding to the second value is determined according to the character encoding table, and the character encoding result corresponding to the second value is determined by using The idea of character encoding, encoding data, the steps are simple, and in the encoding process, the amount of calculation is small. In addition, the above process is completed in the smart contract of the blockchain system, and the whole life cycle of the above operation is recorded through the smart contract, which is convenient for subsequent verification.
此外,如图2所示,本申请实施例还提供了一种数据的字符解码方法,适用于接收端,所述方法包括:In addition, as shown in FIG. 2 , an embodiment of the present application also provides a data character decoding method, which is applicable to a receiving end, and the method includes:
步骤201,根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;
在具体实现时,按照字符编码表确定字符编码结果对应的第二进制的第三数值,将第二进制的第三数值转换为第一进制的第二数值;In the specific implementation, the third numerical value of the second binary system corresponding to the character encoding result is determined according to the character encoding table, and the third numerical value of the second binary system is converted into the second numerical value of the first system;
步骤202,利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;
具体的,如果双方预先约定的编码方法是计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值,则在解码时,将所述阈值转换为第一进制,得到第一进制的阈值;计算所述第二数值和所述第一进制的阈值的差值,即可得到所述第一进制的第一数值。Specifically, if the encoding method pre-agreed by both parties is to calculate the sum of the first numerical value and the threshold value of the first base to obtain the second numerical value of the first base corresponding to the data, then when decoding, the The threshold is converted into the first base to obtain the threshold of the first base; the difference between the second numerical value and the threshold of the first base is calculated to obtain the first numerical value of the first base .
其中,第一进制可以为二进制,第二进制可以为十进制。Wherein, the first system may be binary, and the second binary may be decimal.
步骤203,基于所述第一数值确定解码结果。Step 203: Determine a decoding result based on the first value.
步骤203实际是步骤102的逆步骤,利用二进制的第一数值反推确定字符集中的字符,即解码结果。Step 203 is actually an inverse step of
在本申请实施例中,解码过程实际是编码过程的逆过程,计算量与编码过程是一致的。因此,解码过程的计算量也比较小。In this embodiment of the present application, the decoding process is actually an inverse process of the encoding process, and the amount of calculation is consistent with the encoding process. Therefore, the computational complexity of the decoding process is also relatively small.
此外,图3所示,本申请实施例还提供了一种数据的字符编解码系统,包括:区块链系统301和接收端302;In addition, as shown in FIG. 3 , an embodiment of the present application also provides a character encoding and decoding system for data, including: a
所述区块链系统301,用于获取发送端上传的待编码的数据;调用所述区块链系统的智能合约将所述数据转换为第一进制的第一数值;利用与目标接收端302预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果;向所述接收端302发送所述字符编码结果;The
所述接收端302,用于根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;基于所述第一数值确定解码结果。The receiving
在具体实现时,区块链系统301可以广播字符编码结果,只有拥有相同的阈值的接收端才可以正确解码,正确读取数据;其他接收端即便接收到字符编码结果,由于没有正确的阈值,也无法正确解读数据。In the specific implementation, the
基于同一构思,本申请实施例中提供了一种数据的字符编码装置,适用于区块链系统,该装置的具体实施可参见方法实施例部分的描述,重复之处不再赘述,如图4所示,该装置主要包括:Based on the same concept, the embodiment of the present application provides a data character encoding device, which is suitable for a blockchain system. For the specific implementation of the device, please refer to the description of the method embodiment section, and the repetition will not be repeated, as shown in Figure 4 As shown, the device mainly includes:
获取模块401,用于获取发送端上传的待编码的数据;an
转换模块402,用于调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;A
编码模块403,用于利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;an
第一确定模块404,用于根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。The first determining
在一个具体实施例中,编码模块403,用于调用所述智能合约将所述阈值转换为第一进制,得到第一进制的阈值,并计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值。In a specific embodiment, the
在一个具体实施例中,第一确定模块404,用于调用所述智能合约,将所述第二数值转换为第二进制的第三数值;从所述字符编码表中,读取与所述第三数值对应的字符编码结果。In a specific embodiment, the
在一个具体实施例中,本申请实施例中提供的一种数据的字符编码装置,还包括:约定模块,用于调用所述智能合约,获取所述发送端和所述接收端最后一次会话记录对应的会话标识号;根据所述会话标识号确定与所述接收端预先约定的阈值。In a specific embodiment, the data character encoding device provided in the embodiment of the present application further includes: a contract module, configured to call the smart contract to obtain the last session record of the sender and the receiver The corresponding session identification number; the threshold value pre-agreed with the receiving end is determined according to the session identification number.
在一个具体实施例中,约定模块,用于从所述会话标识号中,读取至少一位目标数据,将所述至少一位目标数据作为与所述接收端预先约定的阈值。In a specific embodiment, the agreement module is configured to read at least one bit of target data from the session identification number, and use the at least one bit of target data as a threshold value pre-agreed with the receiving end.
基于同一构思,本申请实施例中提供了一种数据的字符解码装置,适用于接收端,该装置的具体实施可参见方法实施例部分的描述,重复之处不再赘述,如图5所示,该装置主要包括:Based on the same concept, an embodiment of the present application provides a data character decoding device, which is suitable for a receiving end. For the specific implementation of the device, please refer to the description in the method embodiment section, and the repetition will not be repeated, as shown in FIG. 5 . , the device mainly includes:
第二确定模块501,用于根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;The
解码模块502,用于利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;a
第三确定模块503,用于基于所述第一数值确定解码结果。The third determining
在一个具体实施例中,解码模块502,用于将所述阈值转换为第一进制,得到第一进制的阈值;计算所述第二数值和所述第一进制的阈值的差值,得到所述第一进制的第一数值。In a specific embodiment, the
基于同一构思,本申请实施例中还提供了一种电子设备,如图6所示,该电子设备主要包括:处理器601、存储器602和通信总线603,其中,处理器601和存储器602通过通信总线603完成相互间的通信。其中,存储器602中存储有可被处理器601执行的程序,处理器601执行存储器602中存储的程序,实现如下步骤:Based on the same concept, the embodiment of the present application also provides an electronic device. As shown in FIG. 6 , the electronic device mainly includes: a
获取发送端上传的待编码的数据;Obtain the data to be encoded uploaded by the sender;
调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。Invoke the smart contract of the blockchain system to convert the data into the first numerical value of the first system; encode the first numerical value with the threshold pre-agreed with the receiving end, and obtain the first numerical value corresponding to the data The second numerical value in a hexadecimal system; according to the preset character encoding table, determine the character encoding result corresponding to the second numerical value.
上述电子设备中提到的通信总线603可以是外设部件互连标准(PeripheralComponent Interconnect,简称PCI)总线或扩展工业标准结构(Extended IndustryStandard Architecture,简称EISA)总线等。该通信总线603可以分为地址总线、数据总线、控制总线等。为便于表示,图6中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The
存储器602可以包括随机存取存储器(Random Access Memory,简称RAM),也可以包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。可选地,存储器还可以是至少一个位于远离前述处理器601的存储装置。The
上述的处理器601可以是通用处理器,包括中央处理器(Central ProcessingUnit,简称CPU)、网络处理器(Network Processor,简称NP)等,还可以是数字信号处理器(Digital Signal Processing,简称DSP)、专用集成电路(Application SpecificIntegrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentioned
在本申请的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当该计算机程序在计算机上运行时,使得计算机执行上述实施例中所描述的一种数据的字符编码方法或一种数据的字符解码方法。In yet another embodiment of the present application, a computer-readable storage medium is also provided, where a computer program is stored in the computer-readable storage medium, and when the computer program is run on a computer, the computer is made to execute the above-mentioned embodiments. A character encoding method for data or a character decoding method for data is described.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行该计算机指令时,全部或部分地产生按照本申请实施例所述的流程或功能。该计算机可以是通用计算机、专用计算机、计算机网络或者其他可编程装置。该计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令从一个网站站点、计算机、服务器或者数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、微波等)方式向另外一个网站站点、计算机、服务器或数据中心进行传输。该计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。该可用介质可以是磁性介质(例如软盘、硬盘、磁带等)、光介质(例如DVD)或者半导体介质(例如固态硬盘)等。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer may be a general purpose computer, special purpose computer, computer network, or other programmable device. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, from a website site, computer, server, or data center via wired (e.g., Coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg infrared, microwave, etc.) means to transmit to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes an integration of one or more available media. The available media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes, etc.), optical media (eg, DVDs), or semiconductor media (eg, solid state drives), and the like.
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as "first" and "second" etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these There is no such actual relationship or sequence between entities or operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
以上所述仅是本发明的具体实施方式,使本领域技术人员能够理解或实现本发明。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所申请的原理和新颖特点相一致的最宽的范围。The above descriptions are only specific embodiments of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210193676.1A CN114626338B (en) | 2022-03-01 | 2022-03-01 | Method, system, equipment and storage medium for encoding and decoding characters of data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210193676.1A CN114626338B (en) | 2022-03-01 | 2022-03-01 | Method, system, equipment and storage medium for encoding and decoding characters of data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114626338A true CN114626338A (en) | 2022-06-14 |
CN114626338B CN114626338B (en) | 2024-10-29 |
Family
ID=81899696
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210193676.1A Active CN114626338B (en) | 2022-03-01 | 2022-03-01 | Method, system, equipment and storage medium for encoding and decoding characters of data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114626338B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024061138A1 (en) * | 2022-09-20 | 2024-03-28 | 华为技术有限公司 | Data coding and data decoding method and apparatus, and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107181600A (en) * | 2017-07-27 | 2017-09-19 | 锐捷网络股份有限公司 | A kind of password login authentication method, system and user equipment and certificate server |
CN110932822A (en) * | 2019-12-02 | 2020-03-27 | 泰康保险集团股份有限公司 | Data encoding method, data decoding method, device, equipment and storage medium |
CN112307369A (en) * | 2019-07-31 | 2021-02-02 | 腾讯科技(深圳)有限公司 | A short link processing method, device, terminal and storage medium |
CN112711935A (en) * | 2020-12-11 | 2021-04-27 | 中国科学院深圳先进技术研究院 | Encoding method, decoding method, apparatus and computer readable storage medium |
CN113535997A (en) * | 2021-06-21 | 2021-10-22 | 广州房者荣耀网络科技有限公司 | Processing method, system, device and storage medium for storing graphic data in blockchain |
-
2022
- 2022-03-01 CN CN202210193676.1A patent/CN114626338B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107181600A (en) * | 2017-07-27 | 2017-09-19 | 锐捷网络股份有限公司 | A kind of password login authentication method, system and user equipment and certificate server |
CN112307369A (en) * | 2019-07-31 | 2021-02-02 | 腾讯科技(深圳)有限公司 | A short link processing method, device, terminal and storage medium |
CN110932822A (en) * | 2019-12-02 | 2020-03-27 | 泰康保险集团股份有限公司 | Data encoding method, data decoding method, device, equipment and storage medium |
CN112711935A (en) * | 2020-12-11 | 2021-04-27 | 中国科学院深圳先进技术研究院 | Encoding method, decoding method, apparatus and computer readable storage medium |
CN113535997A (en) * | 2021-06-21 | 2021-10-22 | 广州房者荣耀网络科技有限公司 | Processing method, system, device and storage medium for storing graphic data in blockchain |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024061138A1 (en) * | 2022-09-20 | 2024-03-28 | 华为技术有限公司 | Data coding and data decoding method and apparatus, and device |
Also Published As
Publication number | Publication date |
---|---|
CN114626338B (en) | 2024-10-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100495318C (en) | Integer data compression method, device and decompression method, device | |
JP6931050B2 (en) | Methods and equipment for encoding and decoding binary data | |
CN110445860B (en) | Message sending method, device, terminal equipment and storage medium | |
WO2017054597A1 (en) | Processing method and device for emoji string | |
CN105450232A (en) | Encoding method, decoding method, encoding device and decoding device | |
CN104868922A (en) | Data compression method and device | |
WO2019149006A1 (en) | Method and device for obtaining and providing access information of wireless access point, and medium | |
CN104579360A (en) | Method and equipment for data processing | |
CN106452607B (en) | Method and device for transmitting and analyzing information | |
CN105519065A (en) | Data transmission method and apparatus | |
CN112995199B (en) | Data encoding and decoding method, device, transmission system, terminal equipment and storage medium | |
CN107612866A (en) | A kind of signal modulation/demodulation method and device based on discrete cosine transform | |
CN114626338B (en) | Method, system, equipment and storage medium for encoding and decoding characters of data | |
JPS60140981A (en) | Method and device for decoding digital coded word of coded word system | |
CN112149137B (en) | Vulnerability detection method and device, electronic equipment and computer readable storage medium | |
CN110381056B (en) | Netty-based private protocol encoding and decoding method and device | |
CN103957074A (en) | Data communication method based on intelligent terminal audio port | |
CN110868374A (en) | Security authentication method, server and client device | |
CN104321975A (en) | Wireless communication system and method | |
CN105491544A (en) | Short message compression communication method and short message compression communication system | |
CN113810717A (en) | Image processing method and device | |
CN114095037B (en) | Application program updating method, updating data compression method, device and equipment | |
CN107645665A (en) | A kind of method and device of WebP entropy codes | |
CN111178010B (en) | Method and system for displaying digital signature, data editing method and terminal | |
US10742783B2 (en) | Data transmitting apparatus, data receiving apparatus and method thereof having encoding or decoding functionalities |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |