A multiple reversible image confusion method and system based on gilbert curve and password offset
Patent Information
- Application Number
- CN202511981112.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2045-12-25
AI Technical Summary
面对现实中普遍存在的长宽不等的矩形图像,该方案不得不采取裁剪或边缘填充等预处理手段,这直接导致了原始图像数据的永久丢失或因引入无效冗余而破坏文件结构
1、从原始图像文件中提取图像宽度和图像高度,能够获取图像的几何属性;基于所述图像宽度和所述图像高度建立的一一映射关系和空间填充路径,使得图像中的每一个像素点都能通过一维逻辑索引被唯一标识和访问,为后续的混淆操作提供了无缝适配任意尺寸图像的基础;同时结合基于所述文本密码、所述图像宽度和所述图像高度生成的加密特征因子和位移控制参数,这种结合了自适应几何路径与动态密码偏移的双重混淆机制,在不损失图像原始信息的前提下,破坏了像素间的空间相关性,从而提升了图像混淆的安全性与不可预测性。
Smart Images

Figure CN121864919B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image reconstruction technology, and in particular to a method and system for multiple reversible image obfuscation based on Gilbert curves and cryptographic offsets. Background Technology
[0002] Currently, ensuring the security of image data has become a core issue that urgently needs to be addressed. Early image encryption methods mainly included pixel grayscale transformation, block permutation encryption, and linear scan rearrangement. Among these, while pixel grayscale transformation is computationally simple, it is vulnerable to statistical attacks; block permutation easily produces obvious block artifacts, exposing local texture information; and linear scan rearrangement has limited security effectiveness due to its overly obvious regularity. To overcome the limitations of the above methods, space-filling curves with ergodic properties are used for global pixel scrambling. Because they can effectively destroy the spatial correlation between pixels, they have gradually become a research hotspot in the field of image obfuscation.
[0003] In related technologies, the strict recursive self-similarity property of Hilbert curves is utilized to construct a continuous path on a two-dimensional plane that can traverse all grid points, thereby establishing a mapping relationship between two-dimensional image pixels and one-dimensional data sequences. In practical implementation, existing solutions typically require dividing the image into a standard square grid, and the algorithm strictly follows the geometric path order generated by this grid to read and map image pixels one by one to the new positions. This method, through the complex folding and winding of curves in space, disrupts the arrangement order of adjacent pixels in the original image, thus achieving a certain degree of image information hiding.
[0004] However, the generation rules have rigid requirements on the geometric configuration, forcing the input image to be a square. Faced with rectangular images of varying lengths and widths that are common in reality, this scheme has to resort to preprocessing methods such as cropping or edge padding, which directly leads to the permanent loss of the original image data or the destruction of the file structure due to the introduction of invalid redundancy. Summary of the Invention
[0005] This application provides a reversible image obfuscation method based on Gilbert curves and password offsets, which can be used to adapt to images of arbitrary sizes.
[0006] In a first aspect, this application provides a reversible image obfuscation method based on Gilbert curves and password offsets, comprising: receiving an original image file input by a user and a text password set by the user; extracting the image width and image height from the original image file and calculating the total number of pixels in the original image file; establishing a one-to-one mapping relationship between a one-dimensional logical temporal index of the total number of pixels and two-dimensional physical space coordinates based on the image width and image height, obtaining a space filling path that adapts to the geometric dimensions of the original image file and traverses all pixels; generating encryption feature factors based on the text password, image width, and image height; extracting displacement control parameters from the encryption feature factors according to a preset value range; determining the transformed logical position of each pixel on the one-dimensional logical temporal index according to the space filling path and displacement control parameters; finding the corresponding target physical space coordinates according to the transformed logical positions, and remapping the pixel values of the original image file to the target physical space coordinates, thereby generating target image data.
[0007] By employing the above technical solution, the image width and height can be extracted from the original image file, thus obtaining the image's geometric attributes. Based on the one-to-one mapping relationship and space-filling path established by the image width and height, each pixel in the image can be uniquely identified and accessed through a one-dimensional logical index, providing a seamless foundation for subsequent obfuscation operations that adapt to images of any size. Simultaneously, combined with the encryption feature factor and displacement control parameters generated based on the text password, the image width, and the image height, this dual obfuscation mechanism, combining adaptive geometric paths and dynamic password offsets, destroys the spatial correlation between pixels without losing the original image information, thereby improving the security and unpredictability of image obfuscation.
[0008] In conjunction with some embodiments of the first aspect, in some embodiments, based on the image width and image height, a one-to-one mapping relationship is established between the one-dimensional logical temporal index of the total number of pixels and the two-dimensional physical space coordinates to obtain the spatial filling path that adapts to the geometric size of the original image file and traverses all pixels. Specifically, this includes: determining the initial recursive traversal region based on the image width and image height, and defining a recursive generation function, wherein the recursive generation function receives the region starting coordinates, horizontal scanning vector, and vertical scanning vector of the current recursive region as input parameters for parallel actions; in each recursive execution process, calculating the geometric size of the current recursive region and determining whether it meets the condition of degenerating into a linear structure; if the logical height value of the current recursive region degenerates to 1, it is determined to be a single-row structure, and all pixels in the row are traversed sequentially along the direction of the horizontal scanning vector, recording the two-dimensional physical space coordinates of each pixel, and filling them into the current end of the one-dimensional logical temporal index in sequence; if the logical width ... If the degree value degenerates to 1, the region is determined to be a single-column structure. Following the vertical direction of the scan vector, all pixels within the column are traversed sequentially, recording the two-dimensional physical coordinates of each pixel and filling them into the current end of the one-dimensional logical temporal index. If the current recursive region does not meet the above degradation condition, it indicates that the region is still a two-dimensional plane. The logical width and logical height of the current recursive region are compared. When the logical width is greater than the logical height, a horizontal geometric cut is performed, splitting the current recursive region into multiple sub-regions. When the logical height is greater than the logical width, a vertical geometric cut is performed, splitting the current recursive region into multiple sub-regions. For each sub-region, according to the topological connection rules of the Gilbert curve, the starting coordinates and scan vector direction are adjusted, and the recursive generation function is recursively called until all pixel grid points of the original image file are visited and only visited once. Finally, all recorded coordinate sequences are aggregated to form a spatial filling path that adapts to the geometric size of the original image file and traverses all pixels.
[0009] By employing the above technical solution, the recursive generation function receives the starting coordinates and scan vector of the current recursive region, enabling dynamic perception of the spatial position and orientation of the current processing region. During each recursive execution, by calculating the geometric dimensions and determining the degradation condition (logical height or width degrades to 1), the edge or narrow region of the image can be intelligently identified and processed, ensuring that all pixels are accessed linearly. When the region is still a two-dimensional plane, adaptive horizontal or vertical geometric cutting is performed based on the comparison result of logical width and height, ensuring that the recursive process always performs efficient splitting along the main axis of the image. Finally, by recursively calling and aggregating all recorded coordinate sequences, the resulting space-filling path not only covers rectangular images of any aspect ratio without any additional cropping or filling operations, but also, due to the adoption of the topological connection rules of Gilbert curves, ensures the spatial continuity of the path in the pixel neighborhood, making it applicable to images of different sizes.
[0010] In conjunction with some embodiments of the first aspect, in some embodiments, the step of generating an encryption feature factor based on a text password, image width, and image height, and extracting displacement control parameters from the encryption feature factor according to a preset value range specifically includes: generating a feature string based on a feature function, wherein the feature function is: S = password + "|" + W + "x" + H, where S is the feature string, password is the text password, | is the format separator, x is the connector, W is the image width, and H is the image height; calculating the feature string using a hash algorithm to generate a hash digest, thereby obtaining the encryption feature factor; extracting a preset region and a preset number of bytes from the encryption feature factor; converting the bytes into unsigned long integer values according to parsing rules to obtain an intermediate reference; and performing a modulo operation on the intermediate reference based on the total number of pixels to obtain the displacement control parameters; wherein the modulo operation is: offset = V mod N, where offset is the displacement control parameter, V is the intermediate reference, and N is the total number of pixels.
[0011] By adopting the above technical solution, the user-defined text password is concatenated and bound to the width and height of the image based on the feature string generated by the feature function. This ensures that even if the same password is applied to images of different sizes, or the image size is slightly adjusted, different input sources will be generated. The hash digest generated by the feature string is calculated using a hash algorithm. The irreversibility and avalanche effect of the hash function are utilized to ensure that the generated encrypted feature factor has randomness and collision resistance. Furthermore, byte data is extracted from the encrypted feature factor and converted into unsigned long integer values, mapping the high-dimensional random number space to a numerical space that can be processed by a computer. Finally, the displacement control parameter is obtained by performing a modulo operation on the total number of pixels. Mathematically, the offset must be strictly limited to fall within the valid pixel index range of the image ([0, N-1]), thereby avoiding index out-of-bounds errors and ensuring that each image can obtain a unique offset that is both secure, random, and mathematically valid.
[0012] In conjunction with some embodiments of the first aspect, in some embodiments, before the step of determining the transformed logical position of each pixel on the one-dimensional logical temporal index based on the space filling path and displacement control parameters, the method further includes: receiving an input superposition encryption number parameter, which defines the logical iteration rounds for continuous obfuscation of the same original image; calculating the cumulative displacement vector based on the displacement control parameters and the total number of pixels using an accumulation algorithm; wherein the accumulation algorithm is... In the formula, totalOffset is the cumulative displacement vector, offset is the displacement control parameter, N is the total number of pixels, and count is the number of times the encryption is overlaid. The cumulative displacement vector is regarded as the displacement control parameter, and the step of determining the transformed logical position of each pixel on the one-dimensional logical timing index is performed based on the space filling path and the displacement control parameter.
[0013] By adopting the above technical solution, the input superposition encryption number parameter is received, allowing users to flexibly define the iteration depth of obfuscation to meet the needs of different security levels. Based on the displacement control parameter and the total number of pixels, the cumulative displacement vector is calculated through an accumulation algorithm. Utilizing the linear congruence property of modulo operation, the complex pixel handling operation that originally needed to be repeatedly executed several times (corresponding to count times) in physical memory is mathematically compressed into a simple multiplication and modulo calculation. Treating the cumulative displacement vector as the final displacement control parameter for subsequent steps means that no matter how many superposition times the user sets, the actual physical computation (I / O operations) required to generate the target image data remains unchanged. This design improves the image obfuscation depth and cracking difficulty while eliminating the linear time cost increase brought about by traditional multi-round encryption.
[0014] In conjunction with some embodiments of the first aspect, in some embodiments, the step of remapping the pixel values of the original image file to the target physical space coordinates based on the transformed logical position to generate target image data specifically includes: traversing the source logical time-series index values of the nodes in the space-filling path; finding the corresponding source two-dimensional physical space coordinates of the source logical time-series index values in the space-filling path; and performing a modulo addition operation on the source logical time-series index values using displacement control parameters as step size control factors to calculate the transformed logical position; wherein the operation logic is: In the formula, newPos is the transformed logical position, totalOffset is the cumulative displacement vector, N is the total number of pixels, and i is the number of pixels. Based on the transformed logical position, the space filling path is retrieved to obtain the corresponding target two-dimensional physical space coordinates. The pixel color value at the source two-dimensional physical space coordinates is read and written to the target two-dimensional physical space coordinates in the target image buffer to obtain the target image data.
[0015] By adopting the above technical solution, the source logical temporal index values of the space-filling path are traversed and the source two-dimensional physical space coordinates are found, constructing an ordered set of pixels in the original image. The displacement control parameter is used as a step size control factor to perform a modular addition operation on the source index, realizing a large-scale, non-linear jump in pixel position at the logical level. This jump breaks the original spatial neighborhood relationship of the pixel (resistant to statistical attacks). The calculated transformed logical position, combined with the non-linear characteristics of the Gilbert path, makes the final landing point of the pixel in physical space extremely difficult to predict and has no obvious pattern (resistant to analytical attacks). This achieves deep obfuscation, and because of the one-to-one correspondence of the mapping relationship (bijective), it ensures zero loss of image information during the obfuscation process, providing a guarantee for subsequent reversible restoration.
[0016] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of finding the corresponding target physical space coordinates based on the transformed logical position and remapping the pixel values of the original image file to the target physical space coordinates to generate target image data, the method further includes: decrypting the target image data according to a decryption process corresponding to the encryption process, wherein the writing direction of the decryption process is opposite to that of the encryption process.
[0017] By adopting the above technical solution, the target image data is decrypted according to the decryption process corresponding to the encryption process, thus constructing a complete reversible information security closed loop. Due to the determinism of the Gilbert path itself and the reversibility of the modular operation (within a finite domain), it is ensured that no matter how complex the encryption process is or how high the degree of obfuscation is, as long as the correct password and size information are held, the original image can be restored 100% losslessly. This solves the applicability problem of lossy encryption or irreversible obfuscation in high-precision scenarios such as copyright protection.
[0018] In conjunction with some embodiments of the first aspect, in some embodiments, the step of remapping the pixel values of the original image file to the target physical space coordinates based on the transformed logical position to generate target image data specifically includes: when loading the original image file, obtaining the underlying integer data buffer of the image object through the DataBufferInt method, mapping the two-dimensional grid-like image data to a one-dimensional integer array pixelData stored continuously in memory; dividing the space filling path into several logical segments according to the number of CPU cores of the current computing hardware, and starting a corresponding number of parallel processing threads; each parallel processing thread calculating the mapping relationship within its responsible segment according to the displacement control parameters; the parallel processing threads concurrently reading integer pixel values from the source pixelData array and directly writing them to the offset position of the target array according to the calculated target index.
[0019] By adopting the above technical solution, the underlying integer data buffer is directly obtained through the DataBufferInt method when loading the image, bypassing the cumbersome encapsulation and object creation overhead of high-level image objects (such as BufferedImage), and transforming complex two-dimensional image processing into efficient one-dimensional integer array operations; logical segments are divided according to the number of CPU cores and parallel processing threads are started, which fully taps the computing potential of multi-core processors, enabling the mapping calculation of large-scale pixel data to be executed concurrently; each thread independently calculates and directly writes the offset position of the target array, avoiding resource competition and lock waiting between threads; this combination of direct access to underlying memory and multi-threaded parallelism reduces memory usage and shortens processing time, enabling this method to maintain a fast response when facing obfuscation tasks of ultra-high resolution images such as 4K and 8K.
[0020] Secondly, this application provides a reversible image obfuscation system based on Gilbert curves and cipher offsets. The reversible image obfuscation system based on Gilbert curves and cipher offsets includes: one or more processors and a memory; the memory is coupled to one or more processors, and the memory is used to store computer program code, which includes computer instructions. The one or more processors invoke the computer instructions to cause the reversible image obfuscation system based on Gilbert curves and cipher offsets to perform the method described in the first aspect and any possible implementation thereof.
[0021] Thirdly, this application provides a computer program product containing instructions that, when run on a multiple reversible image obfuscation system based on Gilbert curves and cipher offsets, cause the multiple reversible image obfuscation system based on Gilbert curves and cipher offsets to perform the method described in the first aspect and any possible implementation thereof.
[0022] Fourthly, this application provides a computer-readable storage medium including instructions that, when executed on a multiple reversible image obfuscation system based on Gilbert curves and cipher offsets, cause the multiple reversible image obfuscation system based on Gilbert curves and cipher offsets to perform the method described in the first aspect and any possible implementation thereof.
[0023] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. Extracting the image width and height from the original image file allows us to obtain the image's geometric attributes. The one-to-one mapping relationship and space-filling path established based on the image width and height enable each pixel in the image to be uniquely identified and accessed through a one-dimensional logical index, providing a seamless foundation for subsequent obfuscation operations that adapt to images of any size. Simultaneously, combined with encryption feature factors and displacement control parameters generated based on the text password, image width, and image height, this dual obfuscation mechanism, combining adaptive geometric paths and dynamic password offsets, destroys the spatial correlation between pixels without losing the original image information, thereby improving the security and unpredictability of image obfuscation.
[0024] 2. By utilizing a recursive generation function to receive the starting coordinates and scan vector of the current recursive region, the system can dynamically perceive the spatial position and orientation of the current processing region. During each recursive execution, by calculating the geometric dimensions and determining the degradation condition (logical height or width degenerates to 1), the system can intelligently identify and process the edges or narrow regions of the image, ensuring that all pixels are accessed linearly. When the region is still a two-dimensional plane, adaptive horizontal or vertical geometric cutting is performed based on the comparison result of logical width and height, so that the recursive process always performs efficient splitting along the main axis of the image. Finally, by recursively calling and aggregating all recorded coordinate sequences, the resulting space-filling path not only covers rectangular images of any aspect ratio without any additional cropping or filling operations, but also ensures the spatial continuity of the path in the pixel neighborhood due to the adoption of the topological connection rules of Gilbert curves, making it applicable to images of different sizes.
[0025] 3. The feature string generated by the feature function concatenates and binds the user-defined text password with the width and height of the image, ensuring that even if the same password is applied to images of different sizes, or the image size is slightly adjusted, different input sources will be generated. The hash digest generated by the feature string is calculated using a hash algorithm, which utilizes the irreversibility and avalanche effect of the hash function to ensure that the generated encrypted feature factor has randomness and collision resistance. Furthermore, byte data is extracted from the encrypted feature factor and converted into unsigned long integer values, mapping the high-dimensional random number space to a numerical space that can be processed by a computer. Finally, the displacement control parameter is obtained by performing a modulo operation on the total number of pixels, which mathematically limits the offset to fall within the valid pixel index range of the image ([0, N-1]), thereby avoiding index out-of-bounds errors and ensuring that each image can obtain a unique offset that is both secure, random, and mathematically valid. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating a multi-reversible image obfuscation method based on Gilbert curves and password offsets in an embodiment of this application. Figure 2 This is a schematic diagram of the overall process of a multi-reversible image obfuscation method based on Gilbert curves and password offsets in an embodiment of this application; Figure 3 This is a scene diagram of step S103; Figure 4 This is a schematic diagram of the principle of step S103; Figure 5 This is a flowchart of step S105; Figure 6 This is a flowchart of step S1072; Figure 7 This is a scene diagram of step S1073; Figure 8 This is a scene diagram of step S1074; Figure 9 This is a scene diagram of step S1075; Figure 10 This is a scene diagram of step S108; Figure 11 This is another scenario diagram for step S108; Figure 12 This is a schematic diagram illustrating the effect of the multiple reversible image obfuscation method based on Gilbert curves and password offsets in the embodiments of this application; Figure 13 This is an exemplary hardware structure diagram of a reversible image obfuscation system based on Gilbert curves and cryptographic offsets in an embodiment of this application. Detailed Implementation
[0027] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions a, an, said, the above, and this are intended to also include the plural expressions unless the context clearly indicates otherwise. It should also be understood that the terms used in this application refer to and / or include any or all possible combinations of one or more of the listed items.
[0028] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0029] Please see Figure 1 , Figure 2 , Figure 12 , Figure 1 This is a flowchart illustrating a multi-reversible image obfuscation method based on Gilbert curves and password offsets in an embodiment of this application. Figure 12 This is a schematic diagram illustrating the effect of the multiple reversible image obfuscation method based on Gilbert curves and password offsets in the embodiments of this application; Figure 2 This is a schematic diagram of the overall process of a multi-reversible image obfuscation method based on Gilbert curves and password offsets in an embodiment of this application; A multi-reversible image obfuscation method based on Gilbert curves and cipher offsets includes: S101, Receive the original image file input by the user and the text password set by the user; Among them, the text password refers to a user-defined string of characters used as a unique key to control the image obfuscation process, which determines the generation of subsequent encryption feature factors and the way pixels are offset.
[0030] S102. Extract the image width and image height from the original image file, and calculate the total number of pixels in the original image file; Image width and image height refer to the number of pixels in the horizontal and vertical directions of the image, usually denoted as W and H. The total number of pixels refers to the sum of all the pixels that make up the image, denoted as N, and its value is equal to the product of the width and height.
[0031] Please see Figure 3 , Figure 4 , Figure 3 This is a scene diagram of step S103; Figure 4 This is a schematic diagram of the principle of step S103; S103. Based on the image width and image height, establish a one-to-one mapping relationship between the one-dimensional logical time-series index of the total number of pixels and the two-dimensional physical space coordinates to obtain the geometric size that fits the original image file and the space filling path that traverses all pixels. In this context, the one-dimensional logical temporal index refers to a linear sequence of integers from 0 to N-1, representing the order in which pixels are accessed. The two-dimensional physical spatial coordinates refer to the specific (x, y) coordinates of a pixel in the image. The space-filling path refers to a special connection method (i.e., a Gilbert curve) that passes through every pixel within a rectangular region without repetition or omission.
[0032] Specifically, the system calls the Gilbert curve generation algorithm. The Gilbert curve employs a recursive segmentation strategy, determining whether to cut horizontally or vertically based on the aspect ratio of the current region, thus flexibly and dynamically covering any rectangle. The system generates an array (or list) of length N, where the i-th element stores the coordinates (x, y) of the pixels traversed at the i-th step of the path. This array essentially constructs a lookup table, implementing a bidirectional mapping from logical index i to physical coordinates (x, y) (through forward and reverse lookups).
[0033] In some specific embodiments, step S103 specifically includes: S1031. Determine the initial recursive traversal region based on the image width and image height, and define a recursive generation function, wherein the recursive generation function receives the region start coordinates, horizontal scan vector and vertical scan vector of the current recursive region as input parameters for parallel actions. The initial recursive traversal region represents the rectangular area of the entire image, typically defined as a region starting at coordinates (0, 0), with a width of W and a height of H. The recursive generation function is the core algorithm subroutine that implements the Gilbert curve generation logic, usually named `generate` or `step`. The region starting coordinates refer to the coordinates (x, y) of the top-left corner (or starting logical position) of the currently processed rectangular block. The horizontal and vertical scan vectors are denoted as (ax, ay) and (bx, by), respectively, and are used to represent the local horizontal and vertical growth directions and step sizes of the Gilbert curve in the current recursive level. These two vectors determine the rotation and flipping shape of the curve.
[0034] Specifically, for an image with width W and height H, the initial starting coordinates are set to (0, 0). The initial horizontal scan vector is typically set to (W, 0), and the vertical scan vector is set to (0, H). The design of the recursive generation function is crucial; it does not need to return a value but instead records the generated path by modifying a global list (or array) of coordinates. The function's design follows the mathematical definition of the Generalized Hilbert Curve or Gilbert Curve and is capable of handling non-square aspect ratios.
[0035] S1032. During each recursive execution, calculate the geometric dimensions of the current recursive region and determine whether the conditions for degenerating into a linear structure are met. Here, the geometric dimensions of the current recursive region represent the absolute values of the width and height of the currently processed sub-rectangle, which can be obtained by calculating the magnitude or projected length of vectors (ax, ay) and (bx, by). Degeneration into a linear structure means that the current rectangular region becomes narrowed into a single row with a height of 1 or a single column with a width of 1, at which point two-dimensional segmentation is no longer possible.
[0036] Specifically, upon entering the recursive function body, a boundary check is performed first. The system calculates the effective width w = |ax + ay| and the effective height h = |bx + by| of the current region (for simplification, the actual value needs to be determined based on the vector direction). The condition is: if h = 1, it means the region has been flattened into a row; if w = 1, it means the region has been flattened into a column. This is the recursion termination condition (BaseCase), which determines when to stop segmenting and begin filling the coordinates.
[0037] S1033. If the logical height value of the current recursive region degenerates to 1, it is determined to be a single-row structure. Scan the direction of the vector in the horizontal direction, traverse all the pixels in the row in turn, record the two-dimensional physical space coordinates of each pixel, and fill them into the current end of the one-dimensional logical timing index in order. Here, logical height refers to the vertical span of the current processing block in the local coordinate system. Single-row structure refers to an N×1 pixel bar. One-dimensional logical timing index is the final output path list.
[0038] Specifically, when the height is 1, it means the current region is a straight line. The system no longer performs segmentation but starts a loop. The number of loops equals the width of the line (i.e., the magnitude of the horizontal vector). In each loop, based on the positive or negative direction of the horizontal scan vector (ax, ay) (e.g., (1, 0) represents right, (-1, 0) represents left), the coordinates are accumulated starting from the starting point (x, y), and the coordinates of each pixel along the path are instantiated and added to the result list in order.
[0039] S1034. If the logical width of the current recursive region degenerates to 1, then the region is determined to be a single column structure. Scan the direction of the vertical direction of the vector, traverse all the pixels in the column in turn, record the two-dimensional physical space coordinates of each pixel, and fill them into the current end of the one-dimensional logical timing index in order. Here, logical width refers to the horizontal span of the current processing block in the local coordinate system. Single-column structure refers to a 1×N pixel bar.
[0040] Specifically, the logic is similar to S1033, but it focuses on the vertical direction. When the width is 1, the region is a vertical line. The system starts a loop, and the number of loops equals the height of the column. Based on the direction (up or down) of the vertical scan vector (bx, by), it steps along the direction of the vector from the starting point, appending the coordinates of all pixels along the way to the path sequence in sequence.
[0041] S1035. If the current recursive region does not meet the above degradation conditions, it indicates that the region is still a two-dimensional plane. Compare the logical width and logical height of the current recursive region. S1036. When the logical width is greater than the logical height, perform a horizontal geometric cut to split the current recursive region into multiple sub-regions. S1037. When the logical height is greater than the logical width, perform a vertical geometric cut to split the current recursive region into multiple sub-regions. The logical width and logical height are obtained through the vector magnitude. Geometric cutting refers to dividing a large rectangle into two or three smaller rectangular sub-regions in order to maintain the space-filling property of the Gilbert curve.
[0042] Specifically, this is the core step that distinguishes the Generalized Hilbert (Gilbert) curve from the standard Hilbert curve. The standard Hilbert curve can only be halved (quadritree), while the Gilbert curve adaptively cuts according to the shape.
[0043] If the region appears wide (Width > Height), the system chooses to divide the region in half horizontally (or into three parts, depending on the specific algorithm variant; Gilbert typically uses a bisection). The cut point is usually chosen at the midpoint of the width, w / 2.
[0044] If the region appears to be taller (Height > Width), the system chooses to divide the region into two parts, top and bottom.
[0045] This strategy ensures that the segmented sub-regions tend to be square, thus making the curve structure more stable.
[0046] S1038. For each sub-region, adjust the starting coordinates and scanning vector direction of the input according to the topological connection rules of the Gilbert curve, and recursively call the recursive generation function until all pixel grid points of the original image file are visited and only visited once. Finally, aggregate all the recorded coordinate sequences to form a space filling path that fits the geometric size of the original image file and traverses all pixels.
[0047] Among these, the topological connection rule means that to ensure the continuity of the curve, the connection points between sub-regions must be adjacent, and the entry and exit directions must match. Coordinate sequence aggregation refers to the complete list formed during the recursive natural backtracking process.
[0048] Specifically, suppose the region is divided into two parts, A and B. The system must carefully calculate the end point of part A and the start point of part B. This typically requires rotating or flipping the vectors (ax, ay) and (bx, by) passed to the sub-recursion. For example, when processing the left half, it might be necessary to swap the roles of the horizontal and vertical vectors (corresponding to curve turns). The function calls step(region A parameter) and then step(region B parameter) sequentially. When all recursion stacks return, the coords list is filled with the coordinates of all pixels in order.
[0049] In some embodiments, in a horizontal segmentation scenario: the system divides the current rectangle into left and right halves.
[0050] For the left half: This is an "entry" region. The system calculates a new width vector that is half the original width vector, while the height vector remains unchanged. The generation function is recursively called, passing in the new vector parameters. Note that this actually "scales" the current large rectangle into the smaller rectangle on the left, with the curve shape inherited from the parent.
[0051] For the right half: This is an "exit" region. The system calculates a new starting point, located halfway along the width vector from the original starting point. The remaining width vector is calculated as the original width vector minus the vector of the left half. The generation function is recursively called, passing in the new starting point and vector parameters.
[0052] Vertical segmentation scenario: The system divides the current rectangle into upper and lower halves.
[0053] For the upper part: the width vector remains unchanged, and the height vector is halved. The generation function is called recursively, passing in the new vector parameters.
[0054] For the lower half: Calculate the new starting point, which is located halfway along the height vector from the original starting point. Recursively call the generator function, passing in the new starting point and the remaining height vector.
[0055] Connectivity Guarantee: Due to the mathematical properties of the Gilbert algorithm, the simple binary scaling described above can guarantee that the end point of the left block and the start point of the right block are geometrically adjacent (usually differing by 1 pixel unit), thus forming a connected path.
[0056] As can be seen, by using a recursive generation function to receive the starting coordinates and scan vector of the current recursive region, the spatial position and orientation of the current processing region can be dynamically perceived. In each recursive execution, by calculating the geometric dimensions and judging the degradation condition (logical height or width degenerates to 1), the edges or narrow regions of the image can be intelligently identified and processed, ensuring that all pixels are accessed linearly. When the region is still a two-dimensional plane, adaptive horizontal or vertical geometric cutting is performed based on the comparison result of logical width and height, so that the recursive process always performs efficient splitting along the main axis of the image. Finally, by recursively calling and aggregating all recorded coordinate sequences, the resulting space-filling path not only covers rectangular images of any aspect ratio without any additional cropping or filling operations, but also ensures the height spatial continuity of the path in the pixel neighborhood due to the adoption of the topological connection rules of Gilbert curves, making it applicable to images of different sizes.
[0057] S104. Generate encryption feature factors based on text password, image width, and image height; Among them, the encryption feature factor refers to a binary data digest generated by a specific algorithm that is highly random and unpredictable. It combines cryptographic and image size information and has a unique identification function.
[0058] In some specific embodiments, step S104 includes: S1041. Generate a feature string based on the feature function, where the feature function is S=password+"|"+W+"x"+H; Here, the feature string S refers to the original text data used in subsequent encryption operations; it is a composite string containing both cipher and image geometric information. | and x are predefined delimiters and connectors used to separate data segments with different meanings.
[0059] Specifically, the system constructs a string builder in memory. First, it appends the user's text password (e.g., "MySecret"), then appends the separator "|", followed by the decimal string representation of the image's width (e.g., "1920"), then the concatenation operator "x", and finally the height string (e.g., "1080"). The resulting string is in the form "MySecret|1920x1080". This step strongly binds the password to the physical characteristics of a specific image, achieving a... Figure 1 Dense or one inch apart.
[0060] S1042. Calculate the feature string using a hash algorithm to generate a hash digest and obtain the encryption feature factor; In this context, the hash algorithm refers to SHA-256 or an equivalent one-way hash function. The hash digest is the fixed-length (256-bit) binary data block output by the algorithm. The cryptographic feature factor is this binary digest.
[0061] Specifically, the system calls the encryption library interface. It obtains the UTF-8 byte sequence of the feature string S generated in S1041. It initializes the SHA-256 digester, fills in the byte sequence, and executes the digest() operation. The result is a byte array of length 32 (byte
[32] ). Due to the avalanche effect of the hash algorithm, if the width or height of the characters in S changes by one bit, or the password changes by one bit, the output 32 bytes of data will change.
[0062] Please see Figure 5 , Figure 5 This is a flowchart of step S105; S105. Extract displacement control parameters from the encryption feature factors according to the preset value range; The preset value range refers to the specific position in the hash digest used to extract data (such as the first 8 bytes). The offset control parameter is a non-negative integer (i.e., Offset) ultimately used for mathematical calculations, which determines the step size of pixel transport.
[0063] Specifically, although SHA-256 generates 32 bytes, for computational efficiency and numerical usability, the system typically truncates the first 8 bytes (64 bits) of the hash digest. The system parses these 8 bytes in big-endian format, converting them into an unsigned long integer V. This ensures extremely rich randomness in the numerical value. Finally, to ensure this random number can function within the image pixel range, the system performs a modulo operation on the total number of pixels N using this large integer V, i.e., offset = V mod N. The resulting offset will necessarily fall within the interval [0, N-1], representing a valid shift step.
[0064] In some specific embodiments, step S105 specifically includes: S1051. Extract a preset area and a preset number of bytes of data from the encryption feature factor; The preset region typically refers to the starting position of the digest (index 0). The preset quantity is 8 bytes (64 bits), which is to match the bit width of the subsequent long integer (Longtype).
[0065] Specifically, although 32 bytes of data are generated, only 64-bit integers are needed to provide sufficient random space for generating the shift parameters. The system creates a new 8-byte array or directly manipulates a slice of the existing array to extract the 8 bytes of data with indices [0, 1, 2, 3, 4, 5, 6, 7].
[0066] S1052. Convert the byte data into an unsigned long integer value according to the parsing rules to obtain the intermediate reference; The parsing rule typically refers to big-endian or little-endian. The intermediate reference is the value V corresponding to the 8 bytes of data extracted by S1051.
[0067] Specifically, the system needs to concatenate these 8 fragmented bytes into a single integer. Big-endian order is used: the 0th byte is the most significant bit (MSB), and the 7th byte is the least significant bit (LSB). They are then combined using bit shift operations. This step requires an unsigned long integer, so the sign bit must also be treated as a numeric bit, or a BigInteger class must be used.
[0068] S1053. Perform a modulo operation on the intermediate reference based on the total number of pixels to obtain the displacement control parameters; where the modulo operation is offset = V mod N; The displacement control parameter is the final offset step size used. N is the total number of pixels in the image.
[0069] Specifically, this is a mathematical operation that maps random numbers to a finite range [0, N-1]. The intermediate baseline V could be as large as 2. 64 -1 is a number, while the number of image pixels N may be 10. 6 The system performs division and takes the remainder. The resulting offset ensures that if subsequent addition operations on list indices overflow, their properties conform to the rules of a finite cyclic group.
[0070] As can be seen, the feature string generated by the feature function concatenates and binds the user-defined text password with the width and height of the image, so that even if the same password is applied to images of different sizes, or the image size is slightly adjusted, different input sources will be generated. The hash digest generated by the hash algorithm on the feature string utilizes the irreversibility and avalanche effect of the hash function to ensure that the generated encrypted feature factor has randomness and collision resistance. Furthermore, byte data is extracted from the encrypted feature factor and converted into unsigned long integer values, mapping the high-dimensional random number space to a numerical space that can be processed by a computer. Finally, the displacement control parameter is obtained by performing a modulo operation on the total number of pixels, which mathematically strictly limits the offset to fall within the valid pixel index range of the image ([0, N-1]), thereby avoiding index out-of-bounds errors and ensuring that each image can obtain a unique offset that is both secure, random and mathematically valid.
[0071] S106. Based on the space filling path and displacement control parameters, determine the transformed logical position of each pixel on the one-dimensional logical timing index; Here, the transformed logical position refers to the index value of a pixel in the shuffled new sequence. The one-dimensional logical temporal index is the Gilbert curve access order defined in S103.
[0072] Specifically, this step is the core logic transformation for encryption. The system traverses all pixels (index i from 0 to N-1). For each index i, the system uses the offset parameter calculated in S105 to calculate its new position. This means that every pixel on the Gilbert path moves forward by offset steps along this winding path. Due to the use of modulo operations, if the movement exceeds the end of the path, it will return to the beginning of the path and continue moving, forming a closed-loop cyclic shift. This step only involves mathematical index calculations and has not yet involved writing to physical memory.
[0073] In some preferred embodiments, the above embodiments perform single-round encryption, but for the sake of encryption complexity, multiple rounds of encryption are performed; Before step S106, the method further includes: S201. Receive the input superimposed encryption number of times parameter. The superimposed encryption number of times parameter is used to define the logical iteration rounds of continuous obfuscation of the same original image. The stacking encryption count parameter, usually denoted as `count`, is a non-negative integer (e.g., 1, 10, 1000). It represents how many times the user wants the encryption algorithm to be repeated, serving as an adjustment factor to enhance security. Continuous obfuscation refers to using the output of the previous round of obfuscation as the input for the next round, but in this scheme, logical equivalence is achieved through optimization.
[0074] S202. Based on the displacement control parameters and the total number of pixels, calculate the cumulative displacement vector using an accumulation algorithm; where the accumulation algorithm is totalOffset=(offset×count) modN; The displacement control parameter is the previously calculated single offset. The total number of pixels is N. The cumulative displacement vector totalOffset is a final offset after mathematical optimization.
[0075] Specifically, in traditional multi-encryption, five physical read / write operations of the entire image pixel are required (assuming count=5). However, since the encryption logic of this scheme is based on linear addition of indices (circular shift under modulo operation), it satisfies the associative law. That is, moving offset steps, then moving offset steps again, is equivalent to moving 2×offset steps at once. The system directly uses large number multiplication offset*count, and then takes the modulo of the total number of pixels N. In this way, regardless of whether count is 1 or 1 million, the calculation of totalOffset is a single CPU multiplication instruction, with a time complexity of O(1).
[0076] S203. Treat the cumulative displacement vector as a displacement control parameter and execute S106.
[0077] As can be seen, the parameter for the number of superposition encryption times received as input allows users to flexibly define the iteration depth of obfuscation to meet the needs of different security levels. Based on the displacement control parameter and the total number of pixels, the cumulative displacement vector is calculated through an accumulation algorithm. Utilizing the linear congruence property of modulo operation, the complex pixel handling operation that originally needed to be repeated several times (corresponding to count times) in physical memory is mathematically compressed into a simple multiplication and modulo calculation. Treating the cumulative displacement vector as the final displacement control parameter for subsequent steps means that no matter how many superposition times the user sets, the actual physical computation (I / O operations) required to generate the target image data remains unchanged. This design improves the image obfuscation depth and the difficulty of cracking while eliminating the linear time cost increase brought about by traditional multi-round encryption.
[0078] S107. Find the corresponding target physical space coordinates based on the transformed logical position, and remap the pixel values of the original image file to the target physical space coordinates to generate target image data.
[0079] In this context, the target physical space coordinates refer to the (x, y) position of the pixel on the two-dimensional plane of the image after being offset by the Gilbert path. Remapping refers to the operation of copying the pixel color value from the source address to the destination address. The target image data refers to the image memory data after obfuscation.
[0080] Specifically, this step performs the actual pixel transfer. For each raw index i: 1. Locate the source coordinates in the table generated by S103.
[0081] 2. Based on the new index newIndex calculated in S106, look up the table generated in S103 to find the target coordinates.
[0082] 3. Read the pixel value at (sx, sy) in the source image.
[0083] 4. Write this value to the new image buffer at the position (tx, ty).
[0084] After all N pixels have completed this process, the color points in the image are not only out of order along the Gilbert curve, but also shifted in position as a whole. Originally adjacent pixels may now be far apart, destroying the visual semantics of the image.
[0085] As can be seen, extracting the image width and height from the original image file allows us to obtain the image's geometric attributes. The one-to-one mapping relationship and space-filling path established based on the image width and height enable each pixel in the image to be uniquely identified and accessed through a one-dimensional logical index, providing a seamless foundation for subsequent obfuscation operations that adapt to images of any size. Simultaneously, combined with the encryption feature factor and displacement control parameters generated based on the text password, the image width, and the image height, this dual obfuscation mechanism, which combines adaptive geometric paths and dynamic password offsets, destroys the spatial correlation between pixels without losing the original image information, thereby improving the security and unpredictability of image obfuscation.
[0086] Following the previous example, in some specific embodiments, step S107 specifically includes: S1071, Traverse the source logic timing index values of the nodes in the space-filling path; The source logic timing index value is denoted as i, ranging from 0 to N-1. The space filling path is the pre-generated Curve array or generator.
[0087] Specifically, the system starts a main loop (or a parallel loop), and the counter or iterator i is incremented sequentially. Each iteration represents processing the i-th node on the Gilbert curve. This traversal order is linear (0, 1, 2...), but the corresponding physical pixel positions are randomly skipped.
[0088] Please see Figure 6 , Figure 6 This is a flowchart of step S1072; S1072. The source logic timing index value is used to find the corresponding source two-dimensional physical space coordinates in the space filling path; The source two-dimensional physical space coordinates are denoted as (sx, sy).
[0089] Specifically, within the loop body of S1071, the system accesses the Curve structure. It performs a query operation: Pointp = Curve[i]. This retrieves the position of the current i-th pixel in the original image, for example, (100, 25). These coordinates are the original coordinates of the pixel to be moved.
[0090] Please see Figure 7 , Figure 7 This is a scene diagram of step S1073; S1073. Using the displacement control parameter as the step size control factor, perform a modulo addition operation on the source logic timing index value to calculate the transformed logic position; where the operation logic is newPos=(i+totalOffset) modN; The transformed logical position is either the target index j or newPos.
[0091] Specifically, the system reads the current index i and the totalOffset passed in from S203. It then performs addition and modulo: longj = (i + totalOffset) % N. This step determines which new node on the Gilbert path the pixel should move to.
[0092] Please see Figure 8 , Figure 8 This is a scene diagram of step S1074; S1074. Based on the transformed logical position, retrieve the space filling path and obtain the corresponding target two-dimensional physical space coordinates. The target's two-dimensional physical space coordinates are denoted as (tx, ty).
[0093] Specifically, the system uses the new index newPos calculated by S1073 to look up the table again: PointtargetP = Curve[newPos]. For example, it obtains the coordinates (500, 300). These coordinates are the target position of the pixel.
[0094] Please see Figure 9 , Figure 9 This is a scene diagram of step S1075; S1075. Read the pixel color value at the source two-dimensional physical space coordinates and write it to the target two-dimensional physical space coordinates in the target image buffer to obtain the target image data.
[0095] The pixel color value is typically a 32-bit integer (ARGB) or a 24-bit integer (RGB). The target image buffer is a new, blank image memory area of the same size.
[0096] Specifically, the system performs memory read and write operations: 1.intcolor=sourceImage.getPixel(sx,sy); 2.targetImage.setPixel(tx, ty, color); As can be seen, by traversing the source logical temporal index values of the space-filling path and finding the source two-dimensional physical space coordinates, an ordered set of pixels in the original image is constructed. By using the displacement control parameter as the step size control factor to perform a modular addition operation on the source index, a large-scale, non-linear jump in pixel position is achieved at the logical level. This jump breaks the original spatial neighborhood relationship of the pixel (resistant to statistical attacks). The calculated transformed logical position, combined with the non-linear characteristics of the Gilbert path, makes the final landing point of the pixel in physical space extremely difficult to predict and has no obvious pattern (resistant to analytical attacks). This achieves deep obfuscation, and because of the one-to-one correspondence of the mapping relationship (bijective), it ensures zero loss of image information during the obfuscation process, providing a guarantee for subsequent reversible restoration.
[0097] It's important to note that you cannot directly modify the source graph (in-place); otherwise, subsequent steps will read corrupted data that has already been modified. You must read the source graph and then write a new graph.
[0098] In some specific embodiments, after step S107, the method further includes: Please see Figure 10 , Figure 11 , Figure 10 This is a scene diagram of step S108; Figure 11 This is another scenario diagram for step S108; S108. Decrypt the target image data according to the decryption process corresponding to the encryption process, wherein the writing direction of the decryption process is opposite to that of the encryption process.
[0099] The target image data refers to the obfuscated and encrypted image file generated in the preceding steps. The decryption process refers to the reverse operation of restoring the encrypted image to the original visual image. The reverse writing direction means that in the pixel transfer process, the reverse mathematical mapping relationship is followed (tracing back from the target position to the source position).
[0100] Specifically, the decryption process is the key verification of the reversibility of this scheme. The system first needs to use the exact same text password as during encryption and the width and height extracted from the encrypted image. The system re-executes S103 to generate the exact same Gilbert space-filling path, and re-executes S1041-S1045 and S202 to generate the exact same cumulative displacement vector totalOffset.
[0101] The difference lies in the fact that the pixel transport logic of S601 is the inverse operation of encryption. The system traverses each node index i (representing the pixel position of the decrypted image) on the Gilbert path. According to the formula: oldIndex=(i-totalOffset) modN To locate the pixel's position within the encrypted image. Since modulo operations on negative numbers in programming languages can result in negative values, the actual calculation formula is: oldIndex=(i-totalOffset modN+N) modN The system extracts pixels from the encrypted image based on the calculated oldIndex and places them back into the i-th position of the decrypted image, thereby achieving 100% pixel-level restoration.
[0102] In some embodiments, the process involves forward traversal and reverse writing. For each pixel *i* in the target image, the original position in the encrypted image from which it originated is calculated: source = (i + totalOffset) mod N (Note the different logical perspectives here: if moving from the encrypted image to the decrypted image, the source is added to the offset; if finding the encrypted image from the decrypted image, the offset is subtracted. Typically, for ease of implementation, the approach is to traverse the encrypted image at index *k* and move it to the position (k - totalOffset) mod N).
[0103] In some embodiments, the parameter is inverted. The encryption function is reused, but the passed offset parameter is set to N-totalOffset. This is because in the modulo N group, moving Nx steps is equivalent to moving x steps backward. Thus, there is no need to write a separate decryption function; decryption can be completed by directly calling Encrypt(image, N-offset), which is not limited here.
[0104] As can be seen, by decrypting the target image data according to the decryption process corresponding to the encryption process, a complete reversible information security closed loop is constructed. Due to the determinism of the Gilbert path itself and the reversibility of the modular operation (within a finite domain), it is ensured that no matter how complex the encryption process or how high the degree of obfuscation, as long as the correct password and size information are held, the original image can be restored 100% losslessly. This solves the applicability problem of lossy encryption or irreversible obfuscation in high-precision scenarios such as copyright protection.
[0105] In some preferred embodiments, another implementation of step S107 is as follows: S301. When loading the original image file, the underlying integer data buffer of the image object is obtained through the DataBufferInt method, and the two-dimensional grid-like image data is mapped to a one-dimensional integer array pixelData that is stored continuously in memory. DataBufferInt is a class in the Java AWT / Swing library used for high-performance image processing, representing an int[] array behind the image. The integer data buffer refers to this memory area. A one-dimensional integer array pixelData is a linear array of all pixel color values arranged in row-major order.
[0106] Specifically, in conventional image processing, using `getPixel(x, y)` requires multiple steps, including object encapsulation, coordinate checking, and color model conversion, which is inefficient. This step directly accesses the abstraction layer. For a `BufferedImage` object, the system calls `((DataBufferInt)image.getRaster().getDataBuffer()).getData()`. This line of code directly returns an `int[]` reference in heap memory. At this point, the image is no longer logically two-dimensional (x, y), but a large array of length W×H. Modifying the value at the array index is equivalent to modifying the pixel at (index %W, index / W).
[0107] S302. Based on the number of CPU cores in the current computing hardware, divide the space filling path into several logical segments and start the corresponding number of parallel processing threads. Here, the number of CPU cores refers to the number of logical processors (e.g., 8 cores and 16 threads). A logical segment refers to dividing the total length N of the Gilbert curve into cores parts, with each part having a length of N / cores.
[0108] Specifically, the system calls `Runtime.getRuntime().availableProcessors()` to obtain the number of cores (K). Then, it calculates the task block size for each thread.
[0109] The system creates a thread pool (ThreadPool) or ForkJoinPool to prepare for task submission.
[0110] S303. Each parallel processing thread calculates the mapping relationship within its responsible sub-segment based on the displacement control parameters. The mapping relationship refers to the correspondence from the source array index to the target array index.
[0111] Specifically, this is a purely computational step, without involving memory writes. Thread T_k, based on its responsible range [start, end), loops through the loop variable i from start to end. For each i, it performs the modulo addition operation in S1073: targetIndex = (i + totalOffset) % N. The targetIndex calculated in this step is only a logical index and still needs to be converted into a physical array index using the Gilbert path lookup table (because pixelData is scanned row by row, while Gilbert is meandering).
[0112] In optimized mode, the Curve array directly stores the physical array index (yW+x) instead of the Point object. This allows the memory address offset to be obtained with just one lookup.
[0113] S304. Parallel processing threads concurrently read integer pixel values from the source pixelData array and write them directly to the offset position of the target array according to the calculated target index.
[0114] Wherein, source pixelData and target array refer to the int[] of the original image and the new image, respectively.
[0115] Specifically, the thread performs the assignment: `dstPixels[dstPhys] = srcPixels[srcPhys]`. Since the target position `dstPhys` written by each thread is determined by `i + offset`, and `i` is segmented and non-overlapping, and `i + offset` is also non-overlapping modulo N, the write regions of the target array are mutually exclusive, and there is no race condition. This means that no locking is needed, and each thread can fully utilize the memory bandwidth.
[0116] As can be seen, by directly obtaining the underlying integer data buffer through the DataBufferInt method when loading the image, the cumbersome encapsulation and object creation overhead of high-level image objects (such as BufferedImage) are bypassed, transforming complex two-dimensional image processing into efficient one-dimensional integer array operations. Logical segments are divided according to the number of CPU cores and parallel processing threads are started, fully tapping the computing potential of multi-core processors, enabling concurrent execution of mapping calculations for large-scale pixel data. Each thread independently calculates and directly writes the offset position of the target array, avoiding resource contention and lock waiting between threads. This combination of direct access to underlying memory and multi-threaded parallelism reduces memory usage and shortens processing time, enabling this method to maintain a fast response even when dealing with obfuscation tasks of ultra-high resolution images such as 4K and 8K.
[0117] The following describes an exemplary reversible image obfuscation system 1300 based on Gilbert curves and cryptographic offsets provided in an embodiment of this application. Figure 13 This is an exemplary hardware structure diagram of a multi-reversible image obfuscation system 1300 based on Gilbert curves and cryptographic offsets provided in an embodiment of this application.
[0118] In some embodiments, the Gilbert curve and cryptographic offset-based reversible image obfuscation system 1300 is a computer device or includes a computer device. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores data. The network interface communicates with other external terminals or servers via a network connection. In some embodiments, the network interface can be a wired network interface; in some embodiments, it can also be a wireless network interface. When the computer program is executed by the processor, it implements the methods described in the embodiments of this application.
[0119] Those skilled in the art will understand that Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0120] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0121] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0122] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0123] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A multi-reversible image obfuscation method based on Gilbert curves and cipher offsets, characterized in that, include: Receives the raw image file input by the user and the text password set by the user; Extract the image width and height from the original image file, and calculate the total number of pixels in the original image file; Based on the image width and the image height, a one-to-one mapping relationship is established between the one-dimensional logical temporal index of the total number of pixels and the two-dimensional physical space coordinates, so as to obtain the geometric size that fits the original image file and the space filling path that traverses all pixels. During each recursive execution, the geometric dimensions of the current recursive region are calculated, and it is determined whether the conditions for degenerating into a linear structure are met. If the logical height or logical width of the current recursive region has not degenerated to 1, it indicates that the region is still a two-dimensional plane. Compare the logical width and logical height of the current recursive region. When the logical width is greater than the logical height, perform a horizontal geometric cut to split the current recursive region into multiple sub-regions; When the logical height is greater than the logical width, perform a vertical geometric cut to split the current recursive region into multiple sub-regions; For each sub-region, the starting coordinates and scanning vector direction of the input are adjusted according to the topological connection rules of the Gilbert curve, and the recursive generation function is recursively called until all pixel grid points of the original image file are visited and only visited once. Finally, all recorded coordinate sequences are aggregated to form a space filling path that fits the geometric size of the original image file and traverses all pixels. An encryption feature factor is generated based on the text password, the image width, and the image height; The displacement control parameters are extracted from the encryption feature factors according to a preset value range; The system receives an input parameter for the number of superimposed encryption iterations, which defines the logical iteration rounds for continuously obfuscating the same original image. Based on the displacement control parameters and the total number of pixels, a cumulative displacement vector is calculated using an accumulation algorithm; wherein the accumulation algorithm is: ; In the formula, totalOffset is the cumulative displacement vector, offset is the displacement control parameter, N is the total number of pixels, and count is the superposition encryption number parameter; The cumulative displacement vector is regarded as a displacement control parameter; Based on the space filling path and the displacement control parameters, determine the transformed logical position of each pixel on the one-dimensional logical timing index; Specifically, this includes: traversing the source logical timing index values of the nodes in the space-filling path; The source logical timing index value is used to find the corresponding source two-dimensional physical space coordinates in the space filling path; Using the displacement control parameter as a step size control factor, a modular addition operation is performed on the source logic timing index value to calculate the transformed logic position; wherein the operation logic is as follows: ; In the formula, newPos is the transformed logical position, totalOffset is the cumulative displacement vector, N is the total number of pixels, and i is a pixel; Based on the transformed logical position, the corresponding target physical space coordinates are found, and the pixel values of the original image file are remapped to the target physical space coordinates to generate target image data.
2. The method according to claim 1, characterized in that, The recursive execution process is as follows: The initial recursive traversal region is determined based on the image width and the image height, and a recursive generation function is defined, wherein the recursive generation function receives the region start coordinates, horizontal scan vector and vertical scan vector of the current recursive region as input parameters for parallel actions; After the step of determining whether the conditions for degeneracy to a linear structure are met, the method further includes: If the logical height value of the current recursive region degenerates to 1, it is determined to be a single-row structure. The scanning vector is scanned along the horizontal direction, and all pixels in the row are traversed in turn. The two-dimensional physical space coordinates of each pixel are recorded and filled into the current end of the one-dimensional logical time index in order. If the logical width of the current recursive region degenerates to 1, then the region is determined to be a single-column structure. The scanning vector is directed along the vertical direction, and all pixels in the column are traversed sequentially. The two-dimensional physical space coordinates of each pixel are recorded and filled into the current end of the one-dimensional logical timing index in order.
3. The method according to claim 1, characterized in that, The encryption feature factor is generated based on the text password, the image width, and the image height; The step of extracting displacement control parameters from the encryption feature factor according to a preset value range specifically includes: Generate a feature string based on a feature function, wherein the feature function is: S=password+"|"+W+"x"+H In the formula, S is the feature string, password is the text password, | is the format separator, x is the connector, W is the image width, and H is the image height; The feature string is calculated using a hash algorithm to generate a hash digest, thus obtaining the encryption feature factor; Extract a preset region and a preset number of bytes of data from the encryption feature factors; The byte data is converted into an unsigned long integer value according to the parsing rules to obtain an intermediate reference. The displacement control parameters are obtained by performing a modulo operation on the intermediate reference based on the total number of pixels; wherein the modulo operation is as follows: offset = V mod N In the formula, offset is the displacement control parameter, V is the intermediate reference, and N is the total number of pixels.
4. The method according to claim 1, characterized in that, The step of finding the corresponding target physical space coordinates based on the transformed logical position and remapping the pixel values of the original image file to the target physical space coordinates to generate target image data specifically includes: Based on the transformed logical position, the space filling path is retrieved to obtain the corresponding target two-dimensional physical space coordinates; The pixel color value at the source two-dimensional physical space coordinates is read and written to the target two-dimensional physical space coordinates in the target image buffer to obtain the target image data.
5. The method according to claim 4, characterized in that, After the step of finding the corresponding target physical space coordinates based on the transformed logical position, remapping the pixel values of the original image file to the target physical space coordinates, thereby generating target image data, the method further includes: The target image data is decrypted according to the decryption process corresponding to the encryption process, wherein the writing direction of the decryption process is opposite to that of the encryption process.
6. The method according to claim 1, characterized in that, The step of finding the corresponding target physical space coordinates based on the transformed logical position and remapping the pixel values of the original image file to the target physical space coordinates to generate target image data specifically includes: When loading the original image file, the underlying integer data buffer of the image object is obtained through the DataBufferInt method, and the two-dimensional grid-like image data is mapped to a one-dimensional integer array pixelData that is stored continuously in memory. Based on the number of CPU cores in the current computing hardware, the space filling path is divided into several logical segments, and a corresponding number of parallel processing threads are started. Each parallel processing thread calculates the mapping relationship within its assigned sub-segment based on the displacement control parameters. Parallel processing threads concurrently read integer pixel values from the source pixelData array and write them directly to the offset position of the target array based on the calculated target index.
7. A multi-reversible image obfuscation system based on Gilbert curves and cipher offsets, characterized in that, The Gilbert curve and cipher offset-based reversible image obfuscation system comprises: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors invoke the computer instructions to cause the Gilbert curve and cipher offset-based reversible image obfuscation system to perform the method as described in any one of claims 1-6.
8. A computer program product containing instructions, characterized in that, When the computer program product is run on a multiple reversible image obfuscation system based on Gilbert curves and cipher offsets, the multiple reversible image obfuscation system based on Gilbert curves and cipher offsets performs the method as described in any one of claims 1-6.
9. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on a multiple reversible image obfuscation system based on Gilbert curves and cipher offsets, the multiple reversible image obfuscation system based on Gilbert curves and cipher offsets performs the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Encryption processing system, encryption device, decryption device, program, and encryption processing method
JP2012177893A