# Image-Steganography-Library-Ohos **Repository Path**: chinasoft3_ohos/Image-Steganography-Library-ohos ## Basic Information - **Project Name**: Image-Steganography-Library-Ohos - **Description**: 使用LSB将加密信息编码嵌入到图片中,实现隐写 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-05-21 - **Last Updated**: 2021-09-30 ## Categories & Tags **Categories**: harmonyos-image **Tags**: None ## README # Image-Steganography-Library-Ohos ### 项目介绍 - 项目名称:Image-Steganography-Library-Ohos - 所属系列:openharmony的第三方组件适配移 - 功能:使用LSB将加密信息编码嵌入到图片中,实现隐写 - 项目移植状态:主功能完成 - 调用差异:无 - 开发版本:sdk6,DevEco Studio 2.2 Beta1 - 基线版本:Release v1.1 ### 效果演示 ### 安装教程 1.在项目根目录下的build.gradle文件中, ``` allprojects { repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } } ``` 2.在entry模块的build.gradle文件中, ``` dependencies { implementation 'com.gitee.chinasoft_ohos:ImageSteganography:1.0.1' ...... } ``` 在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 ### 使用说明 How to encode message into an image: - Your Ability class should implements TextEncodingCallback interface and also contains its override methods. ```JAVA public class Encode extends Ability implements TextEncodingCallback ``` - Firstly, instantiate the ImageSteganography object and pass the values Message , Secret Key and Image Bitmap to the constructor. ```JAVA ImageSteganography imageSteganography = new ImageSteganography(message, secret_key, original_image); ``` - Secondly, instantiate the TextEncoding object and pass the values Activity and TextEncodingCallback object to the constructor. ```JAVA TextEncoding textEncoding = new TextEncoding(Encode.this, Encode.this); ``` - Finally, execute our encoding task. ```JAVA textEncoding.inBack(imageSteganography); ``` - OnStartTextEncoding() : In this method you can whatever by the start of text encoding process. ```JAVA @Override public void onStartTextEncoding() { //Whatever you want to do at the start of text encoding } ``` - onCompleteTextEncoding() : After the completion of text encoding, this method is called and gives result. ```JAVA @Override public void onCompleteTextEncoding(ImageSteganography result) { //After the completion of text encoding. //result object is instantiated this.result = result; if (result != null && result.isEncoded()){ //encrypted image bitmap is extracted from result object encoded_image = result.getEncrypted_image(); //set text and image to the UI component. textView.setText("Encoded"); imageView.setImageBitmap(encoded_image); } ``` How to decode message from an image ? - Your Ability class should implements TextDecodingCallback interface and also contains its override methods. ```JAVA public class Decode extends Ability implements TextDecodingCallback ``` - Firstly, instantiate the ImageSteganography object and pass the values Secret Key and Image PixelMap to the constructor. ```JAVA ImageSteganography imageSteganography = new ImageSteganography(secret_key, original_image); ``` - Secondly, instantiate the TextDecoding object and pass the values Activity and TextDecodingCallback object to the constructor. ```JAVA TextDecoding textDecoding = new TextDecoding(Decode.this, Decode.this); ``` - Finally, execute our decoding task. ```JAVA textDecoding.doInBackground(imageSteganography); ``` - OnStartTextDecoding() : In this method you can whatever by the start of text decoding process. ```JAVA @Override public void onStartTextDecoding() { //Whatever you want to do at the start of text encoding } ``` - onCompleteTextDecoding() : After the completion of text decoding, this method is called and gives result. ```JAVA @Override public void onCompleteTextEncoding(ImageSteganography result) { //By the end of textDecoding if (result != null) { if (!result.isDecoded()) whether_encoded.setText("No message found"); else { if (!result.isSecretKeyWrong()) { message.setText("" + result.getMessage()); } else { textView.setText("Wrong secret key"); } } } else { whether_encoded.setText("Select Image First"); } } ``` ### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 ### 版本迭代 - 1.0.1 ### 版权和许可信息 ``` MIT License Copyright (c) 2018 Ayush Agarwal Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ```