CN105763763B - A kind of image encryption method - Google Patents

A kind of image encryption method Download PDF

Info

Publication number
CN105763763B
CN105763763B CN201610082651.9A CN201610082651A CN105763763B CN 105763763 B CN105763763 B CN 105763763B CN 201610082651 A CN201610082651 A CN 201610082651A CN 105763763 B CN105763763 B CN 105763763B
Authority
CN
China
Prior art keywords
value
hexadecimal
values
image
pixel
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.)
Expired - Fee Related
Application number
CN201610082651.9A
Other languages
Chinese (zh)
Other versions
CN105763763A (en
Inventor
李红芳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Technology and Business Institute
Original Assignee
Chongqing Technology and Business Institute
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Chongqing Technology and Business Institute filed Critical Chongqing Technology and Business Institute
Priority to CN201610082651.9A priority Critical patent/CN105763763B/en
Publication of CN105763763A publication Critical patent/CN105763763A/en
Application granted granted Critical
Publication of CN105763763B publication Critical patent/CN105763763B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/32Circuits or arrangements for control or supervision between transmitter and receiver or between image input and image output device, e.g. between a still-image camera and its memory or between a still-image camera and a printer device
    • H04N1/32101Display, printing, storage or transmission of additional information, e.g. ID code, date and time or title
    • H04N1/32144Display, printing, storage or transmission of additional information, e.g. ID code, date and time or title embedded in the image data, i.e. enclosed or integrated in the image, e.g. watermark, super-imposed logo or stamp
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/32Circuits or arrangements for control or supervision between transmitter and receiver or between image input and image output device, e.g. between a still-image camera and its memory or between a still-image camera and a printer device
    • H04N1/32101Display, printing, storage or transmission of additional information, e.g. ID code, date and time or title
    • H04N1/32144Display, printing, storage or transmission of additional information, e.g. ID code, date and time or title embedded in the image data, i.e. enclosed or integrated in the image, e.g. watermark, super-imposed logo or stamp
    • H04N1/32149Methods relating to embedding, encoding, decoding, detection or retrieval operations
    • H04N1/32267Methods relating to embedding, encoding, decoding, detection or retrieval operations combined with processing of the image
    • H04N1/32272Encryption or ciphering

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Image Analysis (AREA)
  • Facsimile Transmission Control (AREA)

Abstract

本发明公开了一种图像加密方法,属于计算机加密领域,通过图像采集设备获取人脸图像,然后根据人脸图像的任一像素点的位置及其RGB值进行密码生成并对图像进行加密。本发明可以根据用户人脸识别后自适应生成密码,密码生成速度快,并能够结合生成的密码对图像进行加密,以对图像进行保护。本发明图像加密过程中,不需要额外对图像进行人工设定密码,而是通过人脸识别装置进行人脸识别后,自动生成唯一的密码,该密码保密程度高且与图像的重组相适应,后期解密时,能够根据密码直接进行图像解密,与传统的图像解密方式相比,本发明不用按照加密过程进行倒推,提高了图像加密的安全性。The invention discloses an image encryption method, which belongs to the field of computer encryption. A face image is acquired through an image acquisition device, and then a password is generated according to the position of any pixel of the face image and its RGB value, and the image is encrypted. The invention can self-adaptively generate a password according to the user's face recognition, has a fast generation speed of the password, and can encrypt an image in combination with the generated password to protect the image. In the image encryption process of the present invention, there is no need to manually set a password for the image, but a unique password is automatically generated after the face recognition device performs face recognition, and the password has a high degree of confidentiality and is compatible with image reorganization. In the later stage of decryption, the image can be decrypted directly according to the password. Compared with the traditional image decryption method, the present invention does not need to reverse the encryption process, which improves the security of image encryption.

Description

一种图像加密方法An Image Encryption Method

技术领域technical field

本发明属于计算机加密领域,特别是涉及一种图像加密方法。The invention belongs to the field of computer encryption, in particular to an image encryption method.

背景技术Background technique

网络图像是以互联网为展示平台和传播媒介,借助多媒体演绎等手段来表现的作品,由于借助强大的网络媒介,网络图像具有快速大范围传播、多样性、互动性等优点,已成为流行文化的重要组成部分。但同样由于网络传播的便捷性,导致网络图像的知识产权不易受到保护,网络盗版侵权给著作者和版权人造成巨额损失,对网络文化的发展造成了严重影响,例如严重影响到摄影作品的收费,以致抑制了摄影行业的长期发展。因此,媒体单位需要对自有版权的新闻图片和素材图片进行版权保护,以防止这些图片被其他单位无偿转载或使用。Network images are works expressed with the help of multimedia deduction and other means using the Internet as a display platform and communication medium. Due to the powerful network media, network images have the advantages of rapid and large-scale transmission, diversity, and interactivity, and have become popular culture. An important part of. But also due to the convenience of network transmission, the intellectual property rights of network images are not easy to be protected. Network piracy and infringement have caused huge losses to authors and copyright owners, and have had a serious impact on the development of network culture, such as seriously affecting the fees charged for photographic works. , so as to inhibit the long-term development of the photography industry. Therefore, media units need to protect their own copyrighted news pictures and material pictures to prevent these pictures from being reprinted or used by other units without compensation.

同时由于用户有时需要通过移动终端共享图片给他人,例如通过WIFI直连、蓝牙等技术将图片共享给他人;在共享过程中,若被第三方获取通信数据,则第三方也可以得到图片内容;甚至有的时候,用户误操作导致连接了第三方用户,误将图片共享给了第三方(如在WIFI直连时连接了第三方用户,而并非共享的用户),导致图片共享安全度低。At the same time, because users sometimes need to share pictures with others through mobile terminals, such as sharing pictures with others through WIFI direct connection, Bluetooth and other technologies; during the sharing process, if the communication data is obtained by a third party, the third party can also obtain the picture content; Even sometimes, the user misuses the user to connect to a third-party user and shares the picture to the third party by mistake (for example, the third-party user is connected to the WIFI direct connection instead of the shared user), resulting in low security of picture sharing.

为了实现对图片的版权保护,现有技术大多通过在图片上添加水印的做法,但现有技术中在图片添加水印的同时,也影响了图像的可观看性,部分简单的水印甚至能够被破解修复,远不能达到图像安全传输及有效保护的目的,同时现有技术还有工作效率低的缺点。In order to realize the copyright protection of pictures, most of the existing technologies add watermarks to the pictures, but in the prior art, adding watermarks to the pictures also affects the viewability of the pictures, and some simple watermarks can even be deciphered Restoration is far from achieving the purpose of secure image transmission and effective protection, and the existing technology also has the disadvantage of low work efficiency.

发明内容Contents of the invention

有鉴于现有技术的上述缺陷,本发明所要解决的技术问题是提供一种能够实现图像安全传输及有效保护的加密方法。In view of the above-mentioned defects in the prior art, the technical problem to be solved by the present invention is to provide an encryption method capable of realizing secure image transmission and effective protection.

为实现上述目的,本发明提供了一种图像加密方法,包括以下步骤:To achieve the above object, the present invention provides a method for image encryption, comprising the following steps:

步骤一、通过图像采集设备获取分辨率为a*a的正方形人脸图像,所述a为正整数;Step 1, obtaining a square human face image with a resolution of a*a by an image acquisition device, where a is a positive integer;

步骤二、设定所述人脸图像中任意一像素点为Pij,获取像素点Pij的RGB值,所述i、j均为正整数,且1≤i≤a,1≤j≤a;Step 2. Set any pixel point in the face image as P ij , and obtain the RGB value of pixel point P ij , where i and j are both positive integers, and 1≤i≤a, 1≤j≤a ;

步骤三、将像素点Pij的R值、G值及B值分别转换为对应的十六进制数值;Step 3, converting the R value, G value and B value of the pixel P ij into corresponding hexadecimal values;

判断像素点Pij的十六进制R值、十六进制G值及十六进制B值是否达到两位;Determine whether the hexadecimal R value, the hexadecimal G value and the hexadecimal B value of the pixel P ij reach two digits;

当像素点Pij的十六进制R值、十六进制G值或十六进制B值不到两位时,在该不到两位的十六进制值左边添加一个字符G,以形成像素点Pij的两位R值字符串、两位G值字符串和两位B值字符串,然后执行步骤四;当像素点Pij的十六进制R值、十六进制G值及十六进制B值达到两位时,直接执行步骤四;When the hexadecimal R value, hexadecimal G value or hexadecimal B value of the pixel P ij is less than two digits, a character G is added to the left of the less than two digit hexadecimal value, To form the two-digit R value character string, the two-digit G value character string and the two-digit B value character string of the pixel point P ij , then perform step 4; when the hexadecimal R value of the pixel point P ij , the hexadecimal value When the G value and the hexadecimal B value reach two digits, go to step 4 directly;

步骤四、将像素点Pij的两位R值字符串、两位G值字符串和两位B值字符串从左向右依次排列形成第一级数串;Step 4, arranging the two-digit R-value character string, the two-digit G-value character string and the two-digit B-value character string of the pixel P ij from left to right to form a first series string;

步骤五、将i和j分别转换为对应的十六进制数值;Step five, converting i and j into corresponding hexadecimal values;

判断i的十六进制值或j的十六进制值是否达到四位;当i的十六进制值或j的十六进制值不到四位时,在该不到四位的十六进制值左边添加字符G,以形成i的四位字符串和j的四位字符串,然后执行步骤六;当i的十六进制值及j的十六进制值达到四位时,执行步骤六;Determine whether the hexadecimal value of i or the hexadecimal value of j reaches four digits; when the hexadecimal value of i or the hexadecimal value of j is less than four digits, the Add the character G to the left of the hexadecimal value to form a four-digit string of i and a four-digit string of j, and then perform step six; when the hexadecimal value of i and the hexadecimal value of j reach four digits , go to Step 6;

步骤六、将j的四位字符串添加到所述第一级数串的左边,且将i的四位字符串添加到所述j的四位字符串的左边,以形成第二级数串;Step 6, adding the four-digit string of j to the left side of the first progression string, and adding the four-digit string of i to the left side of the four-digit string of j to form a second progression string ;

步骤七、将所述人脸图像划分为16*16个正方形区域选取所述像素点Pij所在的区域Tm,n,m、n均为正整数且1≤m≤16、1≤n≤16;Step 7, dividing the face image into 16*16 square regions Select the area T m,n where the pixel P ij is located, where m and n are both positive integers and 1≤m≤16, 1≤n≤16;

步骤八、判断第二级数串中是否有字符G;当第二数串中包含字符G时,将第二级数串中的字符G替换为0,然后执行步骤九;当第二数串中没有字符G时,执行步骤九;Step 8, judge whether there is a character G in the second series of numbers; when the second series of numbers contains the character G, replace the character G in the second series of numbers with 0, and then perform step nine; when the second series of numbers When there is no character G in , perform step nine;

步骤九、设定所述第二级数串的倒数第一位数为Q1,设定所述第二级数串的倒数第二位数为Q2Step 9, setting the penultimate digit of the second series number string to be Q 1 , and setting the penultimate number of the second series number string to be Q 2 ;

将Q1和Q2分别转换为十进制数值;计算Q11=Q1+1得到Q11,计算Q21=Q2+1得到Q21;所述1≤Q11≤16,所述1≤Q21≤16;Convert Q 1 and Q 2 to decimal values respectively; calculate Q 11 =Q 1 +1 to get Q 11 , calculate Q 21 =Q 2 +1 to get Q 21 ; said 1≤Q 11 ≤16, said 1≤Q 21≤16 ;

计算得到第一目标区域Tx,ycalculate Obtain the first target area T x, y ;

将Tm,n与Tx,y进行替换;Replace T m, n with T x, y ;

步骤十、将第一行区域与第三行区域进行替换;将第二行区域与第四行区域进行替换;将第五行区域与第七行区域进行替换;将第六行区域与第八行区域进行替换;将第九行区域与第十一行区域进行替换;将第十行区域与第十二行区域进行替换;将第十三行区域与第十五行区域进行替换;将第十四行区域与第十六行区域进行替换。Step 10. Replace the first line area with the third line area; replace the second line area with the fourth line area; replace the fifth line area with the seventh line area; replace the sixth line area with the eighth line area area; replace the ninth line area with the eleventh line area; replace the tenth line area with the twelfth line area; replace the thirteenth line area with the fifteenth line area; replace the fourteenth line area The line area is replaced with the sixteenth line area.

采用以上技术方案,能够根据用户人脸识别后自适应生成密码,且生成速度快,并能够结合生成的密码对图像进行加密,以对图像进行保护。By adopting the above technical solution, a password can be adaptively generated according to the user's face recognition, and the generation speed is fast, and the image can be encrypted in combination with the generated password to protect the image.

较佳的,所述步骤七中选取所述像素点Pij所在的区域Tm,n按以下步骤进行:Preferably, in the step 7, selecting the area T m,n where the pixel P ij is located is carried out according to the following steps:

计算得到m,计算得到n;根据m和n的值选取区域Tm,ncalculate get m, calculate Obtain n; select the region T m,n according to the values of m and n.

较佳的,步骤一中,通过图像采集设备获取分辨率为a*a的正方形人脸图像按以下步骤进行:Preferably, in step 1, the acquisition of a square human face image with a resolution of a*a by an image acquisition device is performed in the following steps:

通过图像采集设备获取分辨率为a*b的人脸图像,a为水平方向的像素数量,b为垂直方向的像素数量;Obtain a face image with a resolution of a*b by an image acquisition device, where a is the number of pixels in the horizontal direction, and b is the number of pixels in the vertical direction;

判断是否a>b;Determine whether a>b;

当a>b时,计算W1=a-b,得到待增加的个数W1,然后沿垂直方向添加W1个RGB值为﹛0,0,0﹜的像素,然后执行步骤二;When a>b, calculate W 1 = ab, get the number W 1 to be added, then add W 1 pixels with RGB value﹛0,0,0﹜ along the vertical direction, and then perform step 2;

当a<b时,计算W2=b-a,得到待增加的个数W2,然后沿水平方向添加W2个RGB值为﹛0,0,0﹜的像素,并将b的数值赋值给a,然后执行步骤二;When a<b, calculate W 2 =ba, get the number W 2 to be added, then add W 2 pixels with RGB values﹛0,0,0﹜ along the horizontal direction, and assign the value of b to a , and then perform step two;

当a=b时,执行步骤二。When a=b, execute step 2.

本发明还提供了一种图像解密方法,包括以下步骤:The present invention also provides an image decryption method, comprising the following steps:

S1、将加密图像划分为16*16个正方形区域第一行至第四行区域为第一加密模块,第五行至第八行区域为第二加密模块,第九行至第十二行区域为第三加密模块,第十三行至第十六行区域为第四加密模块;S1. Divide the encrypted image into 16*16 square areas The area from the first row to the fourth row is the first encryption module, the area from the fifth row to the eighth row is the second encryption module, the area from the ninth row to the twelfth row is the third encryption module, and the area from the thirteenth row to the sixteenth row is The row area is the fourth encryption module;

S2、接收用户输入的密码;S2. Receive the password input by the user;

S3、判断所述用户输入的密码是否为14位数串;当用户输入的密码为14位数串时,执行步骤S4;当用户输入的密码不是14位数串时,返回执行步骤S2;S3, judging whether the password input by the user is a 14-digit string; when the password input by the user is a 14-digit string, execute step S4; when the password input by the user is not a 14-digit string, return to execute step S2;

S4、判断输入密码中是否有字符G;当密码中包含字符G时,将密码中的字符G替换为0,然后执行步骤S5;当密码中没有字符G时,执行步骤S5;S4. Determine whether there is a character G in the input password; when the password contains the character G, replace the character G in the password with 0, and then perform step S5; when there is no character G in the password, perform step S5;

S5、并行进行区域确定及RGB值转换;S5. Perform region determination and RGB value conversion in parallel;

所述区域确定按以下步骤进行:The region determination is carried out in the following steps:

A1、从左至右提取密码的第1至4位数形成第三级数串,并将其转换成十进制数值U1;从左至右提取密码的第5至8位数形成第四级数串,并将其转换成十进制数值U2A1. Extract the 1st to 4th digits of the password from left to right to form the third series and convert it into a decimal value U 1 ; extract the 5th to 8th digits of the password from left to right to form the fourth series string, and convert it to a decimal value U 2 ;

从左至右提取密码的第14位数,并将其转换成十进制数值U3;从左至右提取密码的第13位数,并将其转换成十进制数值U4Extract the 14th digit of the password from left to right and convert it into a decimal value U 3 ; extract the 13th digit of the password from left to right and convert it into a decimal value U 4 ;

A2、选取待换区域Tr,t,r、t均为正整数且1≤r≤16、1≤t≤16:A2. Select the area to be replaced T r, t , r, t are positive integers and 1≤r≤16, 1≤t≤16:

计算得到r,计算得到t;根据r和t的值选取待换区域Tr,tcalculate get r, calculate Get t; select the area to be replaced T r, t according to the value of r and t;

A3、计算U31=U3+1得到U31,计算U41=U4+1得到U41;所述1≤U31≤16,所述1≤U41≤16;A3. Calculate U 31 =U 3 +1 to get U 31 , calculate U 41 =U 4 +1 to get U 41 ; said 1≤U 31 ≤16, said 1≤U 41 ≤16;

计算得到第二目标区域Tp,q;所述1≤p≤16,所述1≤q≤16;calculate Obtaining the second target region T p,q ; the 1≤p≤16, the 1≤q≤16;

A4、选择Tp,q对应的加密模块,并对该加密模块进行解密:将该加密模块的第一行与该加密模块的第三行进行替换,将该加密模块的第二行与该加密模块的第四行进行替换;A4. Select the encryption module corresponding to T p, q , and decrypt the encryption module: replace the first row of the encryption module with the third row of the encryption module, and replace the second row of the encryption module with the encryption module The fourth line of the module is replaced;

A5、判断是否与Tp,q位于同一个加密模块;当与Tp,q位于同一个加密模块时,执行步骤A6;当与Tp,q不在同一个加密模块时,将所在加密模块进行解密:将所在加密模块的第一行与该加密模块的第三行进行替换,将所在加密模块的第二行与该加密模块的第四行进行替换,然后执行步骤A6;A5. Judgment Whether it is located in the same encryption module as T p, q ; when and T p, q are located in the same encryption module, perform step A6; when When T p, q are not in the same encryption module, the The encryption module where it is located is decrypted: the Replace the first line of the encryption module with the third line of the encryption module, and the Replace the second line of the encryption module with the fourth line of the encryption module, and then perform step A6;

A6、将Tr,t与Tp,q进行替换;A6, replace T r, t with T p, q ;

所述RGB值转换按以下步骤进行:The RGB value conversion is carried out in the following steps:

从左至右提取密码的第9和第10位数形成第五级数串,并将其转换成十进制数值U5;从左至右提取密码的第11和第12位数形成第六级数串,并将其转换成十进制数值U6;从左至右提取密码的第13和第14位数形成第七级数串,并将其转换成十进制数值U7Extract the 9th and 10th digits of the password from left to right to form the fifth series and convert it into a decimal value U 5 ; extract the 11th and 12th digits of the password from left to right to form the sixth series string, and convert it into a decimal value U 6 ; extract the 13th and 14th digits of the password from left to right to form a seventh progression string, and convert it into a decimal value U 7 ;

S6、进行RGB值匹配:S6. Perform RGB value matching:

选取像素点1≤i≤a,1≤j≤a,且i、j、a均为正整数;将的R值、G值及B值分别与U5、U6和U7进行对比;判断的R值是否等于U5,当的R值不等于U5时,结束解密;当的R值等于U5时,判断的G值是否等于U6;当的G值不等于U6时,结束解密;当的G值等于U6时,判断的B值是否等于U7;当的B值不等于U7时,结束解密;当的B值是否等于U7时,执行步骤S7;Select Pixels 1≤i≤a, 1≤j≤a, and i, j, a are all positive integers; Compare the R value, G value and B value with U 5 , U 6 and U 7 respectively; Is the R value equal to U 5 , when When the R value of is not equal to U 5 , end decryption; when When the value of R is equal to U 5 , the judgment Whether the G value of is equal to U 6 ; when When the G value of is not equal to U 6 , end the decryption; when When the G value is equal to U 6 , judge Whether the B value of is equal to U 7 ; when When the B value of is not equal to U 7 , end the decryption; when Whether the value of B is equal to U 7 , execute step S7;

S7、依次判断第一加密模块至第四加密模块,是否已经进行解密;将未进行解密的加密模块进行解密:S7. Determine whether the first encryption module to the fourth encryption module have been decrypted in turn; decrypt the encryption modules that have not been decrypted:

将未解密加密模块的第一行与该加密模块的第三行进行替换,将未解密加密模块的第二行与该加密模块的第四行进行替换。Replace the first line of the undecrypted encryption module with the third line of the encryption module, and replace the second line of the undecrypted encryption module with the fourth line of the encryption module.

本发明的有益效果是:本发明可以根据用户人脸识别后自适应生成密码,密码生成速度快,并能够结合生成的密码对图像进行加密,以对图像进行保护。本发明图像加密过程中,不需要额外对图像进行人工设定密码,而是通过人脸识别装置进行人脸识别后,自动生成唯一的密码,该密码保密程度高且与图像的重组相适应,后期解密时,能够根据密码直接进行图像解密,与传统的图像解密方式相比,本发明不用按照加密过程进行倒推,提高了图像加密的安全性。The beneficial effects of the present invention are: the present invention can self-adaptively generate a password according to the user's face recognition, the password generation speed is fast, and the image can be encrypted in combination with the generated password to protect the image. In the image encryption process of the present invention, there is no need to manually set a password for the image, but a unique password is automatically generated after the face recognition device performs face recognition, and the password has a high degree of confidentiality and is compatible with image reorganization. In the later stage of decryption, the image can be decrypted directly according to the password. Compared with the traditional image decryption method, the present invention does not need to reverse the encryption process, which improves the security of image encryption.

具体实施方式Detailed ways

下面结合实施例对本发明作进一步说明:The present invention will be further described below in conjunction with embodiment:

一种图像加密方法,包括以下步骤:An image encryption method, comprising the steps of:

步骤一、通过图像采集设备获取分辨率为a*a的正方形人脸图像,所述a为正整数;Step 1, obtaining a square human face image with a resolution of a*a by an image acquisition device, where a is a positive integer;

步骤二、设定所述人脸图像中任意一像素点为Pij,获取像素点Pij的RGB值,所述i、j均为正整数,且1≤i≤a,1≤j≤a;Step 2. Set any pixel point in the face image as P ij , and obtain the RGB value of pixel point P ij , where i and j are both positive integers, and 1≤i≤a, 1≤j≤a ;

步骤三、将像素点Pij的R值、G值及B值分别转换为对应的十六进制数值;Step 3, converting the R value, G value and B value of the pixel P ij into corresponding hexadecimal values;

判断像素点Pij的十六进制R值、十六进制G值及十六进制B值是否达到两位;Determine whether the hexadecimal R value, the hexadecimal G value and the hexadecimal B value of the pixel P ij reach two digits;

当像素点Pij的十六进制R值、十六进制G值或十六进制B值不到两位时,在该不到两位的十六进制值左边添加一个字符G,以形成像素点Pij的两位R值字符串、两位G值字符串和两位B值字符串,然后执行步骤四;当像素点Pij的十六进制R值、十六进制G值及十六进制B值达到两位时,执行步骤四;When the hexadecimal R value, hexadecimal G value or hexadecimal B value of the pixel P ij is less than two digits, a character G is added to the left of the less than two digit hexadecimal value, To form the two-digit R value character string, the two-digit G value character string and the two-digit B value character string of the pixel point P ij , then perform step 4; when the hexadecimal R value of the pixel point P ij , the hexadecimal value When the G value and the hexadecimal B value reach two digits, perform step 4;

步骤四、将像素点Pij的两位R值字符串、两位G值字符串和两位B值字符串从左向右依次排列形成第一级数串;Step 4, arranging the two-digit R-value character string, the two-digit G-value character string and the two-digit B-value character string of the pixel P ij from left to right to form a first series string;

步骤五、将i和j分别转换为对应的十六进制数值;Step 5, converting i and j into corresponding hexadecimal values respectively;

判断i的十六进制值或j的十六进制值是否达到四位;当i的十六进制值或j的十六进制值不到四位时,在该不到四位的十六进制值左边添加字符G,以形成i的四位字符串和j的四位字符串,然后执行步骤六;当i的十六进制值及j的十六进制值达到四位时,执行步骤六;Determine whether the hexadecimal value of i or the hexadecimal value of j reaches four digits; when the hexadecimal value of i or the hexadecimal value of j is less than four digits, the Add the character G to the left of the hexadecimal value to form a four-digit string of i and a four-digit string of j, and then perform step six; when the hexadecimal value of i and the hexadecimal value of j reach four digits , go to Step 6;

步骤六、将j的四位字符串添加到所述第一级数串的左边,且将i的四位字符串添加到所述j的四位字符串的左边,以形成第二级数串;Step 6, adding the four-digit string of j to the left side of the first progression string, and adding the four-digit string of i to the left side of the four-digit string of j to form a second progression string ;

步骤七、将所述人脸图像划分为16*16个正方形区域选取所述像素点Pij所在的区域Tm,n,m、n均为正整数且1≤m≤16、1≤n≤16;Step 7, dividing the face image into 16*16 square regions Select the area T m,n where the pixel P ij is located, where m and n are both positive integers and 1≤m≤16, 1≤n≤16;

步骤八、判断第二级数串中是否有字符G;当第二数串中包含字符G时,将第二级数串中的字符G替换为0,然后执行步骤九;当第二数串中没有字符G时,执行步骤九;Step 8, judge whether there is a character G in the second series of numbers; when the second series of numbers contains the character G, replace the character G in the second series of numbers with 0, and then perform step nine; when the second series of numbers When there is no character G in , perform step nine;

步骤九、设定所述第二级数串的倒数第一位数为Q1,设定所述第二级数串的倒数第二位数为Q2Step 9, setting the penultimate digit of the second series number string to be Q 1 , and setting the penultimate number of the second series number string to be Q 2 ;

将Q1和Q2分别转换为十进制数值;计算Q11=Q1+1得到Q11,计算Q21=Q2+1得到Q21;所述1≤Q11≤16,所述1≤Q21≤16;Convert Q 1 and Q 2 to decimal values respectively; calculate Q 11 =Q 1 +1 to get Q 11 , calculate Q 21 =Q 2 +1 to get Q 21 ; said 1≤Q 11 ≤16, said 1≤Q 21≤16 ;

计算得到第一目标区域Tx,ycalculate Obtain the first target area T x, y ;

将Tm,n与Tx,y进行替换;Replace T m, n with T x, y ;

步骤十、将第一行区域与第三行区域进行替换;将第二行区域与第四行区域进行替换;将第五行区域与第七行区域进行替换;将第六行区域与第八行区域进行替换;将第九行区域与第十一行区域进行替换;将第十行区域与第十二行区域进行替换;将第十三行区域与第十五行区域进行替换;将第十四行区域与第十六行区域进行替换。Step 10. Replace the first line area with the third line area; replace the second line area with the fourth line area; replace the fifth line area with the seventh line area; replace the sixth line area with the eighth line area area; replace the ninth line area with the eleventh line area; replace the tenth line area with the twelfth line area; replace the thirteenth line area with the fifteenth line area; replace the fourteenth line area The line area is replaced with the sixteenth line area.

本实施例中,所述步骤七中选取所述像素点Pij所在的区域Tm,n按以下步骤进行:In this embodiment, in the step 7, selecting the area Tm , n where the pixel point P ij is located is performed according to the following steps:

计算得到m,计算得到n;根据m和n的值选取区域Tm,ncalculate get m, calculate Obtain n; select the region T m,n according to the values of m and n.

本实施例中,步骤一中,通过图像采集设备获取分辨率为a*a的正方形人脸图像按以下步骤进行:In this embodiment, in step 1, the acquisition of a square human face image with a resolution of a*a by the image acquisition device is carried out in the following steps:

通过图像采集设备获取分辨率为a*b的人脸图像,a为水平方向的像素数量,b为垂直方向的像素数量;Obtain a face image with a resolution of a*b by an image acquisition device, where a is the number of pixels in the horizontal direction, and b is the number of pixels in the vertical direction;

判断是否a>b;Determine whether a>b;

当a>b时,计算W1=a-b,得到待增加的个数W1,然后沿垂直方向添加W1个RGB值为﹛0,0,0﹜的像素,然后执行步骤二;When a>b, calculate W 1 = ab, get the number W 1 to be added, then add W 1 pixels with RGB value﹛0,0,0﹜ along the vertical direction, and then perform step 2;

当a<b时,计算W2=b-a,得到待增加的个数W2,然后沿水平方向添加W2个RGB值为﹛0,0,0﹜的像素,并将b的数值赋值给a得到增加像素后的a值,然后执行步骤二;When a<b, calculate W 2 =ba, get the number W 2 to be added, then add W 2 pixels with RGB values﹛0,0,0﹜ along the horizontal direction, and assign the value of b to a Get the value of a after adding pixels, and then perform step 2;

当a=b时,执行步骤二。When a=b, execute step 2.

一种图像解密方法,包括以下步骤:An image decryption method, comprising the following steps:

S1、将加密图像划分为16*16个正方形区域第一行至第四行区域为第一加密模块,第五行至第八行区域为第二加密模块,第九行至第十二行区域为第三加密模块,第十三行至第十六行区域为第四加密模块;S1. Divide the encrypted image into 16*16 square areas The area from the first row to the fourth row is the first encryption module, the area from the fifth row to the eighth row is the second encryption module, the area from the ninth row to the twelfth row is the third encryption module, and the area from the thirteenth row to the sixteenth row is The row area is the fourth encryption module;

S2、接收用户输入的密码;S2. Receive the password input by the user;

S3、判断所述用户输入的密码是否为14位数串;当用户输入的密码为14位数串时,执行步骤S4;当用户输入的密码不是14位数串时,返回执行步骤S2;S3, judging whether the password input by the user is a 14-digit string; when the password input by the user is a 14-digit string, execute step S4; when the password input by the user is not a 14-digit string, return to execute step S2;

S4、判断输入密码中是否有字符G;当密码中包含字符G时,将密码中的字符G替换为0,然后执行步骤S5;当密码中没有字符G时,执行步骤S5;S4. Determine whether there is a character G in the input password; when the password contains the character G, replace the character G in the password with 0, and then perform step S5; when there is no character G in the password, perform step S5;

S5、并行进行区域确定及RGB值转换;S5. Perform region determination and RGB value conversion in parallel;

所述区域确定按以下步骤进行:The region determination is carried out in the following steps:

A1、从左至右提取密码的第1至4位数形成第三级数串,并将其转换成十进制数值U1;从左至右提取密码的第5至8位数形成第四级数串,并将其转换成十进制数值U2A1. Extract the 1st to 4th digits of the password from left to right to form the third series and convert it into a decimal value U 1 ; extract the 5th to 8th digits of the password from left to right to form the fourth series string, and convert it to a decimal value U 2 ;

从左至右提取密码的第14位数,并将其转换成十进制数值U3;从左至右提取密码的第13位数,并将其转换成十进制数值U4Extract the 14th digit of the password from left to right and convert it into a decimal value U 3 ; extract the 13th digit of the password from left to right and convert it into a decimal value U 4 ;

A2、选取待换区域Tr,t,r、t均为正整数且1≤r≤16、1≤t≤16:A2. Select the area to be replaced T r, t , r, t are positive integers and 1≤r≤16, 1≤t≤16:

计算得到r,计算得到t;根据r和t的值选取待换区域Tr,tcalculate get r, calculate Get t; select the area to be replaced T r, t according to the value of r and t;

A3、计算U31=U3+1得到U31,计算U41=U4+1得到U41;所述1≤U31≤16,所述1≤U41≤16;A3. Calculate U 31 =U 3 +1 to get U 31 , calculate U 41 =U 4 +1 to get U 41 ; said 1≤U 31 ≤16, said 1≤U 41 ≤16;

计算得到第二目标区域Tp,q;所述1≤p≤16,所述1≤q≤16;calculate Obtaining the second target region T p,q ; the 1≤p≤16, the 1≤q≤16;

A4、选择Tp,q对应的加密模块,并对该加密模块进行解密:将该加密模块的第一行与该加密模块的第三行进行替换,将该加密模块的第二行与该加密模块的第四行进行替换;A4. Select the encryption module corresponding to T p, q , and decrypt the encryption module: replace the first row of the encryption module with the third row of the encryption module, and replace the second row of the encryption module with the encryption module The fourth line of the module is replaced;

A5、判断是否与Tp,q位于同一个加密模块;当与Tp,q位于同一个加密模块时,执行步骤A6;当与Tp,q不在同一个加密模块时,将所在加密模块进行解密:将所在加密模块的第一行与该加密模块的第三行进行替换,将所在加密模块的第二行与该加密模块的第四行进行替换,然后执行步骤A6;A5. Judgment Whether it is located in the same encryption module as T p, q ; when and T p, q are located in the same encryption module, perform step A6; when When T p, q are not in the same encryption module, the The encryption module where it is located is decrypted: the Replace the first line of the encryption module with the third line of the encryption module, and the Replace the second line of the encryption module with the fourth line of the encryption module, and then perform step A6;

A6、将Tr,t与Tp,q进行替换;A6, replace T r, t with T p, q ;

所述RGB值转换按以下步骤进行:The RGB value conversion is carried out in the following steps:

从左至右提取密码的第9和第10位数形成第五级数串,并将其转换成十进制数值U5;从左至右提取密码的第11和第12位数形成第六级数串,并将其转换成十进制数值U6;从左至右提取密码的第13和第14位数形成第七级数串,并将其转换成十进制数值U7Extract the 9th and 10th digits of the password from left to right to form the fifth series and convert it into a decimal value U 5 ; extract the 11th and 12th digits of the password from left to right to form the sixth series string, and convert it into a decimal value U 6 ; extract the 13th and 14th digits of the password from left to right to form a seventh progression string, and convert it into a decimal value U 7 ;

S6、进行RGB值匹配:S6. Perform RGB value matching:

选取像素点1≤i≤a,1≤j≤a,且i、j、a均为正整数;将的R值、G值及B值分别与U5、U6和U7进行对比;判断的R值是否等于U5,当的R值不等于U5时,结束解密;当的R值等于U5时,判断的G值是否等于U6;当的G值不等于U6时,结束解密;当的G值等于U6时,判断的B值是否等于U7;当的B值不等于U7时,结束解密;当的B值是否等于U7时,执行步骤S7;Select Pixels 1≤i≤a, 1≤j≤a, and i, j, a are all positive integers; Compare the R value, G value and B value with U 5 , U 6 and U 7 respectively; Is the R value equal to U 5 , when When the R value of is not equal to U 5 , end decryption; when When the value of R is equal to U 5 , the judgment Whether the G value of is equal to U 6 ; when When the G value of is not equal to U 6 , end the decryption; when When the G value is equal to U 6 , judge Whether the B value of is equal to U 7 ; when When the B value of is not equal to U 7 , end the decryption; when Whether the value of B is equal to U 7 , execute step S7;

S7、依次判断第一加密模块至第四加密模块,是否已经进行解密;将未进行解密的加密模块进行解密:S7. Determine whether the first encryption module to the fourth encryption module have been decrypted in turn; decrypt the encryption modules that have not been decrypted:

将未解密加密模块的第一行与该加密模块的第三行进行替换,将未解密加密模块的第二行与该加密模块的第四行进行替换。Replace the first line of the undecrypted encryption module with the third line of the encryption module, and replace the second line of the undecrypted encryption module with the fourth line of the encryption module.

以上详细描述了本发明的较佳具体实施例。应当理解,本领域的普通技术人员无需创造性劳动就可以根据本发明的构思作出诸多修改和变化。因此,凡本技术领域中技术人员依本发明的构思在现有技术的基础上通过逻辑分析、推理或者有限的实验可以得到的技术方案,皆应在由权利要求书所确定的保护范围内。The preferred specific embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make many modifications and changes according to the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning or limited experiments on the basis of the prior art shall be within the scope of protection defined by the claims.

Claims (3)

1. a kind of image encryption method, it is characterised in that include the following steps:
Step 1: obtaining the square facial image that resolution ratio is a*a by image capture device, a is positive integer;
Step 2: setting in the facial image any one pixel as Pij, obtain pixel PijRgb value, described i, j are Positive integer, and 1≤i≤a, 1≤j≤a;
Step 3: by pixel PijR values, G values and B values be respectively converted into corresponding hexadecimal values;
Judge pixel PijHexadecimal R values, hexadecimal G values and hexadecimal B values whether reach two;
As pixel PijHexadecimal R values, hexadecimal G values or hexadecimal B values less than two when, this less than two A character G is added on the hexadecimal value left side, to form pixel PijTwo R values character strings, two G values character strings and two B value character strings, then execute step 4;As pixel PijHexadecimal R values, hexadecimal G values and hexadecimal B values reach At two, step 4 is executed;
Step 4: by pixel PijTwo R values character strings, two G values character strings and two B values character strings from left to right successively Arrangement form the first series string;
Step 5: i and j are respectively converted into corresponding hexadecimal values;
Whether the hexadecimal value of the hexadecimal value or j that judge i reaches four;When the hexadecimal value of i or the hexadecimal of j When value is less than four, character G is added on the hexadecimal value left side less than four, with formed i four character strings and j four Position character string, then executes step 6;When the hexadecimal value of the hexadecimal value of i and j reaches four, step 6 is executed;
Step 6: four character strings of j to be added to the left side of the first series string, and four character strings of i are added to The left side of four character strings of the j, to form the second series string;
Step 7: the facial image is divided into 16*16 square areaChoose institute State pixel PijThe region T at placeM, n, m, n are positive integer and 1≤m≤16,1≤n≤16;
Step 8: judging whether there is character G in the second series string;When in the second series string including character G, by the second series string In character G replace with 0, then execute step 9;When there is no character G in the second series string, step 9 is executed;
Step 9: setting the digit last of the second series string as Q1, set the penultimate of the second series string Number is Q2
By Q1And Q2It is respectively converted into decimal value;Calculate Q11=Q1+ 1 obtains Q11, calculate Q21=Q2+ 1 obtains Q21;Described 1 ≤Q11≤ 16, the 1≤Q21≤16;
It calculatesObtain first object region TX, y
By TM, nWith TX, yIt is replaced;
Step 10: the first row region and the third line region are replaced;Second row region is replaced with fourth line region; Fifth line region and the 7th row region are replaced;6th row region is replaced with the 8th row region;By the 9th row area Domain is replaced with the tenth a line region;Tenth row region is replaced with the 12nd row region;By the tenth zone domain with Tenth five-element region is replaced;Ariadne region and the 16th row region are replaced.
2. a kind of image encryption method as described in claim 1, it is characterized in that:The pixel P is chosen in the step 7ij The region T at placeM, nIt carries out according to the following steps:
It calculatesM is obtained, is calculatedObtain n;According to the value chosen area T of m and nM, n
3. a kind of image encryption method as described in claim 1, it is characterized in that:In step 1, obtained by image capture device It is that the square facial image of a*a carries out according to the following steps to take resolution ratio:
The facial image that resolution ratio is a*b is obtained by image capture device, a is the pixel quantity of horizontal direction, and b is Vertical Square To pixel quantity;
Judge whether a>b;
Work as a>When b, W is calculated1=a-b obtains number W to be increased1, then vertically add W1A rgb value Wei ﹛ 0,0, The pixel of 0 ﹜, then executes step 2;
Work as a<When b, W is calculated2=b-a obtains number W to be increased2, W is then added in the horizontal direction2A rgb value Wei ﹛ 0,0, The pixel of 0 ﹜, and the numerical value of b is assigned to a, then execute step 2;
As a=b, step 2 is executed.
CN201610082651.9A 2016-02-05 2016-02-05 A kind of image encryption method Expired - Fee Related CN105763763B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610082651.9A CN105763763B (en) 2016-02-05 2016-02-05 A kind of image encryption method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610082651.9A CN105763763B (en) 2016-02-05 2016-02-05 A kind of image encryption method

Publications (2)

Publication Number Publication Date
CN105763763A CN105763763A (en) 2016-07-13
CN105763763B true CN105763763B (en) 2018-08-31

Family

ID=56329665

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610082651.9A Expired - Fee Related CN105763763B (en) 2016-02-05 2016-02-05 A kind of image encryption method

Country Status (1)

Country Link
CN (1) CN105763763B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109657487B (en) * 2018-12-24 2021-07-06 北京百度网讯科技有限公司 Image processing method, image verification method and device
CN110634173A (en) * 2019-09-05 2019-12-31 北京无限光场科技有限公司 Picture mark information adding method and device, electronic equipment and readable medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1583322A2 (en) * 2004-04-02 2005-10-05 Microsoft Corporation A method and system for recovering password protected private data via a communication network without exposing the private data
CN101976321A (en) * 2010-09-21 2011-02-16 北京工业大学 Generated encrypting method based on face feature key
CN102761418A (en) * 2012-07-16 2012-10-31 重庆电子工程职业学院 Character compression encrypting method
CN103489151A (en) * 2013-09-11 2014-01-01 河南大学 Color image encryption method based on chaos sequence and hyper-chaos system
WO2015180237A1 (en) * 2014-05-28 2015-12-03 东莞盛世科技电子实业有限公司 Method for checking password in fuzzy mode and password checking device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8997177B2 (en) * 2006-05-24 2015-03-31 Confident Technologies, Inc. Graphical encryption and display of codes and text

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1583322A2 (en) * 2004-04-02 2005-10-05 Microsoft Corporation A method and system for recovering password protected private data via a communication network without exposing the private data
CN101976321A (en) * 2010-09-21 2011-02-16 北京工业大学 Generated encrypting method based on face feature key
CN102761418A (en) * 2012-07-16 2012-10-31 重庆电子工程职业学院 Character compression encrypting method
CN103489151A (en) * 2013-09-11 2014-01-01 河南大学 Color image encryption method based on chaos sequence and hyper-chaos system
WO2015180237A1 (en) * 2014-05-28 2015-12-03 东莞盛世科技电子实业有限公司 Method for checking password in fuzzy mode and password checking device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于高级加密标准的图像置乱方法研究及其硬件设计;张浩亮;《硕士论文库》;20110928;全文 *

Also Published As

Publication number Publication date
CN105763763A (en) 2016-07-13

Similar Documents

Publication Publication Date Title
CN103427979B (en) A kind of Internet picture transparent safety transmission method based on chaos encryption
CN104040934B (en) Image privacy is protected when being manipulated by cloud service
CN104851070B (en) A kind of image encryption and decryption method based on foreground and background separation
CN109981256B (en) White box block cipher construction method and system based on Feistel Box structure
CN107094072B (en) A Hybrid Chaos Encryption Method Based on Generalized Henon Map
CN104268825B (en) A kind of method that image procossing is carried out to ciphertext graph picture
Lee et al. Digital image sharing by diverse image media
CN108650434A (en) A kind of method of image encryption
CN105763763B (en) A kind of image encryption method
Wen et al. Triple-image bit-level encryption algorithm based on double cross 2D hyperchaotic map
CN107392970A (en) A kind of digital image encryption algorithm based on bit plane and high-dimension chaotic system
CN107833174A (en) A kind of image encryption method based on Logistic chaos system algorithms
CN104506543B (en) A kind of security certification system and its authentication method based on optical signal
CN113407955A (en) Image encryption method, medium, equipment and terminal based on four-dimensional hyper-chaotic system
CN106875323B (en) Information hiding method and device based on image encryption
CN105554344A (en) Multi-image encryption method based on mixed graphics primitives
CN107734208A (en) A kind of coloured image encipher-decipher method based on HSV space
CN108174053B (en) A Decrypted Area-Limited Image Encryption Method for Directed Area and Playing Card Mapping
CN110634096A (en) An adaptive multi-modal information hiding method and device
TW201414258A (en) Chaotic image encryption method for cloud album
WO2018090685A1 (en) Image data encryption method and apparatus, and network camera
CN116886270B (en) A three-band encryption method based on the national secret algorithm and dual chaos system
Ajmera et al. Video Steganography: Using Scrambling-AES Encryption and DCT, DST Steganography
CN113868690B (en) Trusted deposit certificate based privacy calculation method and system
CN116055024A (en) Encryption Method for Multiple Maps and Multiple Regions of Interest Based on DNA Sequence and Chaotic System

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20180831

Termination date: 20190205