CN114626338B - Method, system, equipment and storage medium for encoding and decoding characters of data - Google Patents
Method, system, equipment and storage medium for encoding and decoding characters of data Download PDFInfo
- Publication number
- CN114626338B CN114626338B CN202210193676.1A CN202210193676A CN114626338B CN 114626338 B CN114626338 B CN 114626338B CN 202210193676 A CN202210193676 A CN 202210193676A CN 114626338 B CN114626338 B CN 114626338B
- Authority
- CN
- China
- Prior art keywords
- value
- base
- data
- character encoding
- threshold value
- 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.)
- Active
Links
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)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
- Document Processing Apparatus (AREA)
Abstract
本申请涉及一种数据的字符编码、解码方法、系统、设备及存储介质;其中,所述编码方法包括:获取发送端上传的待编码的数据;调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。本申请用以解决现有技术中,利用对称或非对称加密的算法比较繁琐的技术问题。
The present application relates to a data character encoding, decoding method, system, device and storage medium; wherein the encoding method comprises: obtaining the data to be encoded uploaded by the sending end; calling the smart contract of the blockchain system to convert the data into a first value in the first base; encoding the first value using a threshold value pre-agreed with the receiving end to obtain a second value in the first base corresponding to the data; and determining the character encoding result corresponding to the second value according to a preset character encoding table. The present application is used to solve the technical problem in the prior art that the algorithm using symmetric or asymmetric encryption is relatively cumbersome.
Description
技术领域Technical Field
本申请涉及区块链技术领域,尤其涉及一种数据的字符编码、解码方法、系统、设备及存储介质。The present application relates to the field of blockchain technology, and in particular to a data character encoding, decoding method, system, device and storage medium.
背景技术Background Art
目前,大部分敏感数据加密场景的解决方案都是通过对称或非对称加密来进行,在端到端的业务流程中,保证中间人可见不可读,上述传统方案适用于绝大部分场景。At present, most solutions for sensitive data encryption scenarios are implemented through symmetric or asymmetric encryption. In the end-to-end business process, it is ensured that the data is visible but not readable by middlemen. The above traditional solutions are applicable to most scenarios.
但是,对于发送端,需要预先配置加密算法,在发送敏感数据时,调用加密算法,利用加密算法对待发送的敏感数据进行加密,算法比较繁琐,计算量大,使得方案比较笨重。However, for the sending end, the encryption algorithm needs to be pre-configured. When sending sensitive data, the encryption algorithm is called to encrypt the sensitive data to be sent. The algorithm is relatively complicated and the calculation amount is large, making the solution cumbersome.
发明内容Summary of the invention
本申请提供了一种数据的字符编码、解码方法、系统、设备及存储介质,用以解决现有技术中,利用对称或非对称加密的算法比较繁琐的技术问题。The present application provides a data character encoding, decoding method, system, device and storage medium to solve the technical problem in the prior art that the algorithm using symmetric or asymmetric encryption is relatively complicated.
第一方面,本申请实施例提供了一种数据的字符编码方法,适用于区块链系统,所述方法包括:In a first aspect, an embodiment of the present application provides a data character encoding method applicable to a blockchain system, the method comprising:
获取发送端上传的待编码的数据;Get the data to be encoded uploaded by the sender;
调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。The smart contract of the blockchain system is called to convert the data into a first numerical value in the first base; the first numerical value is encoded using a threshold value pre-agreed with the receiving end to obtain a second numerical value in the first base corresponding to the data; and a character encoding result corresponding to the second numerical value is determined according to a preset character encoding table.
可选的,所述利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值,包括:Optionally, encoding the first value by using a threshold value pre-agreed with the receiving end to obtain a second value in the first base corresponding to the data includes:
调用所述智能合约将所述阈值转换为第一进制,得到第一进制的阈值,并计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值。The smart contract is called to convert the threshold into the first base to obtain the threshold in the first base, and the sum of the first value and the threshold in the first base is calculated to obtain a second value in the first base corresponding to the data.
可选的,所述根据预设的字符编码表,确定与所述第二数值对应的字符编码结果,包括:Optionally, determining the character encoding result corresponding to the second value according to a preset character encoding table includes:
调用所述智能合约,将所述第二数值转换为第二进制的第三数值;Calling the smart contract to convert the second value into a third binary value;
从所述字符编码表中,读取与所述第三数值对应的字符编码结果。A character encoding result corresponding to the third value is read from the character encoding table.
可选的,所述区块链系统中存储有所述发送端和所述接收端最后一次会话记录;所述利用与接收端预先约定的阈值对所述第一数值进行编码之前,还包括:Optionally, the blockchain system stores the last conversation record between the sending end and the receiving end; before encoding the first value using the threshold value pre-agreed with the receiving end, the method further includes:
调用所述智能合约,获取所述发送端和所述接收端最后一次会话记录对应的会话标识号;Calling the smart contract to obtain a session identification number corresponding to the last session record between the sending end and the receiving end;
根据所述会话标识号确定与所述接收端预先约定的阈值。A threshold value pre-agreed with the receiving end is determined according to the session identification number.
可选的,所述根据所述会话标识号确定与所述接收端预先约定的阈值,包括:Optionally, determining a threshold value pre-agreed with the receiving end according to the session identification number includes:
从所述会话标识号中,读取至少一位目标数据,将所述至少一位目标数据作为与所述接收端预先约定的阈值。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 threshold value pre-agreed with the receiving end.
第二方面,本申请实施例提供了一种数据的字符解码方法,适用于接收端,所述方法包括:In a second aspect, an embodiment of the present application provides a data character decoding method, applicable to a receiving end, the method comprising:
根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;Determine, according to a preset character encoding table, a second value in the first base corresponding to the character encoding result;
利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;Decoding the second value using a threshold value pre-agreed with the transmitting end to obtain a first value in a first base;
基于所述第一数值确定解码结果。A decoding result is determined based on the first value.
可选的,所述利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值,包括:Optionally, the decoding the second value by using a threshold value pre-agreed with the transmitting end to obtain the first value in the first base includes:
将所述阈值转换为第一进制,得到第一进制的阈值;Convert the threshold value into the first base to obtain the threshold value of the first base;
计算所述第二数值和所述第一进制的阈值的差值,得到所述第一进制的第一数值。The difference between the second value and the threshold value in the first system is calculated to obtain the first value in the first system.
第三方面,本申请实施例提供了一种数据的字符编解码系统,包括:区块链系统和接收端;In a third aspect, an embodiment of the present application provides a data character encoding and decoding system, including: a blockchain system and a receiving end;
所述区块链系统,用于获取发送端上传的待编码的数据;调用所述区块链系统的智能合约将所述数据转换为第一进制的第一数值;利用与目标接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果;向所述接收端发送所述字符编码结果;The blockchain system is used to obtain the data to be encoded uploaded by the sending end; call the smart contract of the blockchain system to convert the data into a first value in the first base; encode the first value using a threshold value pre-agreed with the target receiving end to obtain a second value in the first base corresponding to the data; determine a character encoding result corresponding to the second value according to a preset character encoding table; and send the character encoding result to the receiving end;
所述接收端,用于根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;基于所述第一数值确定解码结果。The receiving end is used to determine a second numerical value in the first base corresponding to a character encoding result according to a preset character encoding table; decode the second numerical value using a threshold value pre-agreed with the sending end to obtain a first numerical value in the first base; and determine a decoding result based on the first numerical value.
第四方面,本申请实施例提供了一种电子设备,包括:处理器、存储器和通信总线,其中,处理器和存储器通过通信总线完成相互间的通信;In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a communication bus, wherein the processor and the memory communicate with each other via the communication bus;
所述存储器,用于存储计算机程序;The memory is used to store computer programs;
所述处理器,用于执行所述存储器中所存储的程序,实现第一方面所述的数据的字符编码方法或第二方面所述的数据的字符解码方法。The processor is used to execute the program stored in the memory to implement the data character encoding method described in the first aspect or the data character decoding method 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, which, when executed by a processor, implements the data character encoding method described in the first aspect or the data character decoding method described in the second aspect.
本申请实施例提供的上述技术方案与现有技术相比具有如下优点:本申请实施例提供的该方法,利用发送端和接收端预先约定的阈值对待编码的数据的第一数值进行编码,得到第二数值,之后根据字符编码表,确定第二数值对应的字符编码结果,利用字符编码的思想,对数据进行编码,步骤简单,且在编码过程中,计算量小。而且,上述过程均在区块链系统的智能合约中完成,通过智能合约记录上述操作的全程生命周期,便于后续查证。The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application uses the threshold value pre-agreed by the sending end and the receiving end to encode the first value of the data to be encoded to obtain the second value, and then determines the character encoding result corresponding to the second value according to the character encoding table, and uses the idea of character encoding to encode the data, with simple steps and small amount of calculation during the encoding 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 by the smart contract, which is convenient for subsequent verification.
附图说明BRIEF DESCRIPTION OF THE 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 drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
图1为本申请实施例提供的一种数据的字符编码方法的流程示意图;FIG1 is a schematic diagram of a flow chart of a data character encoding method provided in an embodiment of the present application;
图2为本申请实施例提供的一种数据的字符解码方法的流程示意图;FIG2 is a schematic diagram of a flow chart of a method for character decoding of data provided in an embodiment of the present application;
图3为本申请实施例提供的一种数据的字符编解码系统的结构示意图;FIG3 is a schematic diagram of the structure of a data character encoding and decoding system provided in an embodiment of the present application;
图4为本申请实施例提供的一种数据的字符编码装置的结构示意图;FIG4 is a schematic diagram of the structure of a data character encoding device provided in an embodiment of the present application;
图5为本申请实施例提供的一种数据的字符解码装置的结构示意图;FIG5 is a schematic diagram of the structure of a data character decoding device provided in an embodiment of the present application;
图6为本申请实施例提供的一种电子设备的结构示意图。FIG6 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
为了解决现有技术中,利用对称或非对称加密的算法比较繁琐的技术问题,本申请实施例提供了一种数据的字符编码方法,如图1所示,本申请实施例提供的一种数据的字符编码方法,适用于区块链系统,该数据的字符编码方法具体包括如下步骤:In order to solve the technical problem that the algorithm using symmetric or asymmetric encryption is relatively cumbersome in the prior art, an embodiment of the present application provides a data character encoding method. As shown in FIG1 , a data character encoding method provided in an embodiment of the present application is applicable to a blockchain system. The data character encoding method specifically includes the following steps:
步骤101,获取发送端上传的待编码的数据;Step 101, obtaining the data to be encoded uploaded by the sending end;
其中,数据可以是敏感数据,例如:用户的手机号、身份证号、家庭住址等隐私数据;还可以是其他数据,例如:发送端向接收端发送的会话内容等。The data may be sensitive data, such as the user's mobile phone number, ID number, home address and other private data; it may also be other data, such as the conversation content sent from the sender to the receiver.
步骤102,调用所述区块链系统的智能合约将所述数据转换为第一进制的第一数值;Step 102, calling the smart contract of the blockchain system to convert the data into a first numerical value in the first base;
为了数据能够在计算机中存储以及通过通信网络传输,需要将字符集中的字符编码为指定集合中的某一个对象,例如:比特模式、自然数序列、8位组或者电脉冲等等。常见的例子包括:将拉丁字母表编码成摩斯电码和ASCII。其中,ASCII将字母、数字和其它符号编号,并用7比特的二进制来表示这个整数。通常会额外使用一个扩充的比特,共8比特,以便于以1个字节的方式存储。In order for data to be stored in computers and transmitted over communication networks, the characters in a character set need to be encoded into 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. ASCII numbers letters, numbers, and other symbols and represents the integer using 7 bits of binary. Usually an additional extended bit is used, for a total of 8 bits, to facilitate storage in 1 byte.
在具体实现时,第一进制可以是二进制,将待编码的数据转换为二进制的第一数值。In a specific implementation, the first system may be binary, and the data to be encoded is converted into a first binary value.
步骤103,利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;Step 103, encoding the first value using a threshold value pre-agreed with the receiving end to obtain a second value in the first system corresponding to the data;
其中,与接收端预先约定的阈值需要全局唯一,以防止其他接收到字符编码结果的客户端解读出来。The threshold value pre-agreed with the receiving end needs to be globally unique to prevent other clients that receive the character encoding result from being interpreted.
在一个具体实施例中,所述区块链系统中存储有所述发送端和所述接收端最后一次会话记录;所述利用与接收端预先约定的阈值对所述第一数值进行编码之前,还包括:In a specific embodiment, the blockchain system stores the last conversation record between the sender and the receiver; before encoding the first value using the threshold value pre-agreed with the receiver, the method further includes:
调用所述智能合约,获取所述发送端和所述接收端最后一次会话记录对应的会话标识号;Calling the smart contract to obtain a session identification number corresponding to the last session record between the sending end and the receiving end;
根据所述会话标识号确定与所述接收端预先约定的阈值。A threshold value 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 upon by the sender and the receiver through the session identification number can ensure the global uniqueness of the threshold and prevent other clients from deciphering the information after receiving it. At the same time, as time goes by, the last session between the sender and the receiver is constantly changing and is not fixed. This prevents the same threshold from being used for a long time and being imitated by someone with ulterior motives, further ensuring the security of encoding and decoding using the threshold.
在具体实现时,从所述会话标识号中,读取至少一位目标数据,将所述至少一位目标数据作为与所述接收端预先约定的阈值。In a 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 threshold value pre-agreed with the receiving end.
会话标识号通常由一串数字和字母组成,在确定阈值时,可以从会话标识号中截取其中一段作为阈值。例如:可以读取会话标识号的最后6位目标数据作为预先约定的阈值。当然,也可以是其他位数的目标数据。The session ID is usually composed of a string of numbers and letters. When determining the threshold, a segment of the session ID can be intercepted as the threshold. For example, the last 6 digits of the target data of the session ID can be read as the pre-agreed threshold. Of course, other digits of target data can also be used.
在利用与接收端预先约定的阈值对第一数值进行编码时,可以调用所述智能合约将所述阈值转换为第一进制,得到第一进制的阈值,并计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值。When the first numerical value is encoded using a threshold value pre-agreed with the receiving end, the smart contract can be called to convert the threshold value into the first base to obtain the threshold value in the first base, and the sum of the first numerical value and the threshold value in the first base is calculated to obtain a second numerical value in the first base 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 base as binary, the binary codes corresponding to "sensitive data" are: 110010101001111, 110000100011111, 110010101110000, 110001101101110. The threshold is 5, then 5 is converted to binary 101; then the threshold is added to the binary code, and the second value obtained is 10010101010100, 110000100100100, 110010101110101, 110001101110011.
此外,除了计算第一数值和第一进制的阈值的和进行编码,得到第一进制的第二数值之外,还可以计算第一数值和第一进制的阈值的差值或者乘积或者商,得到第一进制的第二数值。当然,也可以采用其他的编码方法。只要发送端和接收端预先约定好即可。In addition, in addition to calculating the sum of the first value and the threshold value in the first system for encoding to obtain the second value in the first system, the difference, product or quotient of the first value and the threshold value in the first system can also be calculated to obtain the second value in the first system. Of course, other encoding methods can also be used, as long as the sending end and the receiving end agree in advance.
在本申请实施例中,利用阈值对数据进行编码的整个过程仅涉及进制的转换和简单的加、减、乘或除计算,十分简单。但是,对于接收端,只要没有正确的阈值,则无法得到正确的解码结果,无法知晓传递的具体内容。In the embodiment of the present application, the entire process of encoding data using a threshold value only involves base conversion and simple addition, subtraction, multiplication or division calculations, which is very simple. However, for the receiving end, as long as there is no correct threshold value, 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 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), also known as the storage format, is a sequence of integer values (called code units) of a coded character set that are converted from non-negative integer values (i.e., abstract code points) to integer values of finite bit length (called code units). This is a null mapping to itself for fixed-length encodings, but for variable-length encodings, the mapping is more complex, mapping some code points to one code unit and others to a sequence of multiple code units. For example, using 16-bit 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 code space 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 simply chooses units large enough to ensure that all values in the coded 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 8 bits (such as most traditional non-CJK (Chinese, Japanese, Korean and Vietnamese unified ideographic characters) character set encodings), and it is also reasonable enough for coded character sets that can be represented using 16 bits (such as early versions of Unicode). However, as the size of coded character sets increases (for example, the current Unicode character set requires at least 21 bits to represent all of them), this direct representation becomes increasingly inefficient, and it is difficult for existing computer systems to adapt to larger code values. Therefore, many systems using the latest versions of Unicode either use UTF-8, which maps Unicode code points to variable-length 8-bit byte sequences, or UTF-16, which maps code points to variable-length 16-bit sequences.
在具体实现时,调用所述智能合约,将所述第二数值转换为第二进制的第三数值;从所述字符编码表中,读取与所述第三数值对应的字符编码结果。其中,第二进制可以为十进制。In a specific implementation, the smart contract is called to convert the second value into a third value in binary format, and the character encoding result corresponding to the third value is read from the character encoding table, wherein the binary format may be decimal.
为了便于理解,这里继续举例说明,以第二进制为十进制为例,在步骤103的举例中,第二数值为10010101010100、110000100100100、110010101110101、110001101110011,根据步骤104的描述,将上述第二数值转换为十进制,得到第三数值为25940、24868、25973、25459。若字符编码表为UTF-8,查表确定每个数字对应的内容,则最终的字符编码结果为“UTF-8 25940|24868|25973|25459”对应的内容。For ease of understanding, here we continue to give examples, taking the binary system as a decimal system as an example, in the example of step 103, the second value is 10010101010100, 110000100100100, 110010101110101, 110001101110011, according to the description of step 104, the above second value is converted into a decimal system, and the third value is 25940, 24868, 25973, 25459. If the character encoding table is UTF-8, the content corresponding to each number is determined by looking up the table, and the final character encoding result is the content corresponding to "UTF-8 25940|24868|25973|25459".
上述得到的字符串,即作为数据编码之后的结果,对于某些阈值不可见的客户端,数据不可读。但对于阈值可见的客户端,可以人为或系统反加工得到具体内容,计算量小,十分方便。而且,本身在数据传输的过程中也需要将数据转换为二进制,本申请实施例顺势而为,步骤简单,计算量小,十分灵活。The character string obtained above, i.e., the result after data encoding, is unreadable for some clients whose thresholds are not visible. However, for clients whose thresholds are visible, the specific content can be obtained by manual or system reverse processing, which has a small amount of calculation and is very convenient. Moreover, in the process of data transmission, the data also needs to be converted into binary. The embodiment of the present application follows the trend, has simple steps, small amount of calculation, and is very flexible.
在本申请实施例中,利用发送端和接收端预先约定的阈值对待编码的数据的第一数值进行编码,得到第二数值,之后根据字符编码表,确定第二数值对应的字符编码结果,利用字符编码的思想,对数据进行编码,步骤简单,且在编码过程中,计算量小。此外,上述过程均在区块链系统的智能合约中完成,通过智能合约记录上述操作的全程生命周期,便于后续查证。In the embodiment of the present application, the first value of the data to be encoded is encoded using the threshold value pre-agreed by the transmitting 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. The idea of character encoding is used to encode the data, and the steps are simple, and the amount of calculation is small during the encoding process. In addition, the above process is completed in the smart contract of the blockchain system, and the entire 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 , the embodiment of the present application further provides a data character decoding method, which is applicable to a receiving end, and the method includes:
步骤201,根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;Step 201, determining a second value in the first base corresponding to the character encoding result according to a preset character encoding table;
在具体实现时,按照字符编码表确定字符编码结果对应的第二进制的第三数值,将第二进制的第三数值转换为第一进制的第二数值;In a specific implementation, the third binary value corresponding to the character encoding result is determined according to the character encoding table, and the third binary value is converted into the second value of the first base;
步骤202,利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;Step 202, decoding the second value using a threshold value pre-agreed with the transmitting end to obtain a first value in a first base;
具体的,如果双方预先约定的编码方法是计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值,则在解码时,将所述阈值转换为第一进制,得到第一进制的阈值;计算所述第二数值和所述第一进制的阈值的差值,即可得到所述第一进制的第一数值。Specifically, if the encoding method agreed upon in advance by both parties is to calculate the sum of the first numerical value and the threshold of the first base to obtain the second numerical value of the first base corresponding to the data, then during decoding, 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.
其中,第一进制可以为二进制,第二进制可以为十进制。The first system may be binary, and the second system may be decimal.
步骤203,基于所述第一数值确定解码结果。Step 203: determine a decoding result based on the first value.
步骤203实际是步骤102的逆步骤,利用二进制的第一数值反推确定字符集中的字符,即解码结果。Step 203 is actually the reverse step of step 102, and uses the first binary value to reversely determine the character in the character set, that is, the decoding result.
在本申请实施例中,解码过程实际是编码过程的逆过程,计算量与编码过程是一致的。因此,解码过程的计算量也比较小。In the embodiment of the present application, the decoding process is actually the inverse process of the encoding process, and the amount of calculation is consistent with that of the encoding process. Therefore, the amount of calculation in the decoding process is also relatively small.
此外,图3所示,本申请实施例还提供了一种数据的字符编解码系统,包括:区块链系统301和接收端302;In addition, as shown in FIG3 , the embodiment of the present application further provides a data character encoding and decoding system, including: a blockchain system 301 and a receiving end 302;
所述区块链系统301,用于获取发送端上传的待编码的数据;调用所述区块链系统的智能合约将所述数据转换为第一进制的第一数值;利用与目标接收端302预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果;向所述接收端302发送所述字符编码结果;The blockchain system 301 is used to obtain the data to be encoded uploaded by the sending end; call the smart contract of the blockchain system to convert the data into a first value in the first base; encode the first value using a threshold value pre-agreed with the target receiving end 302 to obtain a second value in the first base corresponding to the data; determine a character encoding result corresponding to the second value according to a preset character encoding table; and send the character encoding result to the receiving end 302;
所述接收端302,用于根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;基于所述第一数值确定解码结果。The receiving end 302 is used to determine a second numerical value in the first base corresponding to the character encoding result according to a preset character encoding table; decode the second numerical value using a threshold pre-agreed with the sending end to obtain a first numerical value in the first base; and determine a decoding result based on the first numerical value.
在具体实现时,区块链系统301可以广播字符编码结果,只有拥有相同的阈值的接收端才可以正确解码,正确读取数据;其他接收端即便接收到字符编码结果,由于没有正确的阈值,也无法正确解读数据。In a specific implementation, the blockchain system 301 can broadcast the character encoding results, and only the receiving end with the same threshold can correctly decode and read the data; even if other receiving ends receive the character encoding results, they cannot correctly interpret the data because they do not have the correct threshold.
基于同一构思,本申请实施例中提供了一种数据的字符编码装置,适用于区块链系统,该装置的具体实施可参见方法实施例部分的描述,重复之处不再赘述,如图4所示,该装置主要包括:Based on the same concept, a data character encoding device is provided in the embodiment of the present application, which is applicable to the blockchain system. The specific implementation of the device can refer to the description of the method embodiment part, and the repeated parts will not be repeated. As shown in FIG4, the device mainly includes:
获取模块401,用于获取发送端上传的待编码的数据;The acquisition module 401 is used to acquire the data to be encoded uploaded by the sending end;
转换模块402,用于调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;A conversion module 402, configured to call a smart contract of the blockchain system to convert the data into a first numerical value in a first base;
编码模块403,用于利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;The encoding module 403 is used to encode the first value by using a threshold value pre-agreed with the receiving end to obtain a second value of the first system corresponding to the data;
第一确定模块404,用于根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。The first determining module 404 is configured to determine a character encoding result corresponding to the second value according to a preset character encoding table.
在一个具体实施例中,编码模块403,用于调用所述智能合约将所述阈值转换为第一进制,得到第一进制的阈值,并计算所述第一数值和所述第一进制的阈值的和,得到所述数据对应的第一进制的第二数值。In a specific embodiment, the encoding module 403 is used to call the smart contract to convert the threshold into the first base, obtain the threshold in the first base, and calculate the sum of the first value and the threshold in the first base to obtain the second value in the first base corresponding to the data.
在一个具体实施例中,第一确定模块404,用于调用所述智能合约,将所述第二数值转换为第二进制的第三数值;从所述字符编码表中,读取与所述第三数值对应的字符编码结果。In a specific embodiment, the first determination module 404 is used to call the smart contract to convert the second value into a third binary value; and read the character encoding result corresponding to the third value from the character encoding table.
在一个具体实施例中,本申请实施例中提供的一种数据的字符编码装置,还包括:约定模块,用于调用所述智能合约,获取所述发送端和所述接收端最后一次会话记录对应的会话标识号;根据所述会话标识号确定与所述接收端预先约定的阈值。In a specific embodiment, a character encoding device for data provided in an embodiment of the present application further includes: an agreement module, used to call the smart contract to obtain the session identification number corresponding to the last session record between the sending end and the receiving end; and determine a threshold pre-agreed with the receiving end based on the session identification number.
在一个具体实施例中,约定模块,用于从所述会话标识号中,读取至少一位目标数据,将所述至少一位目标数据作为与所述接收端预先约定的阈值。In a specific embodiment, the agreement module is used 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 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. The specific implementation of the device can refer to the description of the method embodiment part, and the repeated parts will not be repeated. As shown in FIG5, the device mainly includes:
第二确定模块501,用于根据预设的字符编码表,确定与字符编码结果对应的第一进制的第二数值;The second determination module 501 is used to determine a second value in the first base corresponding to the character encoding result according to a preset character encoding table;
解码模块502,用于利用与发送端预先约定的阈值,对所述第二数值进行解码,得到第一进制的第一数值;A decoding module 502, configured to decode the second value using a threshold value pre-agreed with the transmitting end to obtain a first value in a first system;
第三确定模块503,用于基于所述第一数值确定解码结果。The third determination module 503 is configured to determine a decoding result based on the first value.
在一个具体实施例中,解码模块502,用于将所述阈值转换为第一进制,得到第一进制的阈值;计算所述第二数值和所述第一进制的阈值的差值,得到所述第一进制的第一数值。In a specific embodiment, the decoding module 502 is used to convert the threshold into a first base to obtain a threshold in the first base; and calculate the difference between the second value and the threshold in the first base to obtain a first value in the first base.
基于同一构思,本申请实施例中还提供了一种电子设备,如图6所示,该电子设备主要包括:处理器601、存储器602和通信总线603,其中,处理器601和存储器602通过通信总线603完成相互间的通信。其中,存储器602中存储有可被处理器601执行的程序,处理器601执行存储器602中存储的程序,实现如下步骤:Based on the same concept, an electronic device is also provided in an embodiment of the present application, as shown in FIG6 , the electronic device mainly includes: a processor 601, a memory 602 and a communication bus 603, wherein the processor 601 and the memory 602 communicate with each other through the communication bus 603. The memory 602 stores a program executable by the processor 601, and the processor 601 executes the program stored in the memory 602 to implement the following steps:
获取发送端上传的待编码的数据;Get the data to be encoded uploaded by the sender;
调用所述区块链系统的智能合约,将所述数据转换为第一进制的第一数值;利用与接收端预先约定的阈值对所述第一数值进行编码,得到所述数据对应的第一进制的第二数值;根据预设的字符编码表,确定与所述第二数值对应的字符编码结果。The smart contract of the blockchain system is called to convert the data into a first numerical value in the first base; the first numerical value is encoded using a threshold value pre-agreed with the receiving end to obtain a second numerical value in the first base corresponding to the data; and a character encoding result corresponding to the second numerical value is determined according to a preset character encoding table.
上述电子设备中提到的通信总线603可以是外设部件互连标准(PeripheralComponent Interconnect,简称PCI)总线或扩展工业标准结构(Extended IndustryStandard Architecture,简称EISA)总线等。该通信总线603可以分为地址总线、数据总线、控制总线等。为便于表示,图6中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus 603 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus 603 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in FIG6 , but it does not mean that there is only one bus or one type of bus.
存储器602可以包括随机存取存储器(Random Access Memory,简称RAM),也可以包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。可选地,存储器还可以是至少一个位于远离前述处理器601的存储装置。The memory 602 may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the processor 601.
上述的处理器601可以是通用处理器,包括中央处理器(Central ProcessingUnit,简称CPU)、网络处理器(Network Processor,简称NP)等,还可以是数字信号处理器(Digital Signal Processing,简称DSP)、专用集成电路(Application SpecificIntegrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentioned processor 601 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., and can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
在本申请的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当该计算机程序在计算机上运行时,使得计算机执行上述实施例中所描述的一种数据的字符编码方法或一种数据的字符解码方法。In another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program runs on a computer, the computer executes a data character encoding method or a data character decoding method described in the above embodiments.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行该计算机指令时,全部或部分地产生按照本申请实施例所述的流程或功能。该计算机可以是通用计算机、专用计算机、计算机网络或者其他可编程装置。该计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令从一个网站站点、计算机、服务器或者数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、微波等)方式向另外一个网站站点、计算机、服务器或数据中心进行传输。该计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。该可用介质可以是磁性介质(例如软盘、硬盘、磁带等)、光介质(例如DVD)或者半导体介质(例如固态硬盘)等。In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using 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 instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instruction is transmitted from a website site, a computer, a server or a data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integration. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape, etc.), an optical medium (such as a DVD) or a semiconductor medium (such as a solid-state hard disk), etc.
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this article, 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 such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
以上所述仅是本发明的具体实施方式,使本领域技术人员能够理解或实现本发明。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所申请的原理和新颖特点相一致的最宽的范围。The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims (9)
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 CN114626338A (en) | 2022-06-14 |
CN114626338B true 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) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117793361A (en) * | 2022-09-20 | 2024-03-29 | 华为技术有限公司 | Methods, devices and equipment for data encoding and data decoding |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113535997A (en) * | 2021-06-21 | 2021-10-22 | 广州房者荣耀网络科技有限公司 | Processing method, system, device and storage medium for storing graphic data in blockchain |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107181600B (en) * | 2017-07-27 | 2019-12-06 | 锐捷网络股份有限公司 | Password login authentication method and system, user equipment and authentication server |
CN112307369A (en) * | 2019-07-31 | 2021-02-02 | 腾讯科技(深圳)有限公司 | A short link processing method, device, terminal and storage medium |
CN110932822B (en) * | 2019-12-02 | 2022-06-17 | 泰康保险集团股份有限公司 | Data encoding method, data decoding method, device, equipment and storage medium |
CN112711935B (en) * | 2020-12-11 | 2023-04-18 | 中国科学院深圳先进技术研究院 | Encoding method, decoding method, apparatus, and computer-readable storage medium |
-
2022
- 2022-03-01 CN CN202210193676.1A patent/CN114626338B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113535997A (en) * | 2021-06-21 | 2021-10-22 | 广州房者荣耀网络科技有限公司 | Processing method, system, device and storage medium for storing graphic data in blockchain |
Also Published As
Publication number | Publication date |
---|---|
CN114626338A (en) | 2022-06-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2017054597A1 (en) | Processing method and device for emoji string | |
US9998145B2 (en) | Data processing method and device | |
US20160134601A1 (en) | Using a Hash of a Filename to Control Encoding/Decoding of a Digital File | |
CN110601819B (en) | Processing method for random number, block chain link point device and storage medium | |
CN110717151B (en) | Digital fingerprint processing and signature processing method | |
CN114626338B (en) | Method, system, equipment and storage medium for encoding and decoding characters of data | |
CN112995199B (en) | Data encoding and decoding method, device, transmission system, terminal equipment and storage medium | |
CN117278211A (en) | Domain name encryption method, decryption method and device based on content distribution network | |
CN112149137B (en) | Vulnerability detection method and device, electronic equipment and computer readable storage medium | |
CN113688601A (en) | Watermark generation method and device based on form, electronic equipment and computer medium | |
CN110381056B (en) | Netty-based private protocol encoding and decoding method and device | |
CN103402185A (en) | Private information transfer method | |
CN115442073B (en) | Encryption method, decryption method, electronic equipment and storage medium for digital string | |
CN109194536A (en) | A kind of network flow filter method, device and terminal | |
CN106161021A (en) | Private data sending method and device, private data method of reseptance and device | |
CN104636377A (en) | Data compression method and equipment | |
CN111953473A (en) | A signal processing method and device | |
CN109739553B (en) | Parameter configuration method, device, terminal and storage medium | |
CN118215037A (en) | Secondary number identification method, device, equipment, medium and program product | |
CN118199992A (en) | Data encryption method, device, electronic device and storage medium | |
WO2016145616A1 (en) | Method, device, and system for information transmission | |
CN105491544A (en) | Short message compression communication method and short message compression communication system | |
CN111178010B (en) | Method and system for displaying digital signature, data editing method and terminal | |
CN112468993B (en) | Message sending method, receiving method, device and equipment | |
CN117675254A (en) | Device authentication method and related equipment |
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 |