打开eclipse,选择“File->new->Android Applicantion Project”,然后弹出“New Project Applicantion”界面,此时我们可以对工程进行命名,在这里我们填写工程名为“Cryptography”,更改包名为"com.suguniang.cryptography",然后点击右下角的按钮“Next->Next”,接着弹出图标界面设计对话框,选择自己准备好的图标,然后点击"Next->Next->Finish",创建完成项目之后,会弹出到layout界面上,我们就可以进行代码编写:在左边的树状关系菜单中,右键点击“layout”,创建一个新的XML文件,即“layout->New->Android Xml File”,然后会弹出一个“New Anroid Xml File”对话框,在第三个文本框中输入新建XML文件的名称,在这里我们输入"opt_first",然后点击"Finish"完成创建,接着我们就开始编写代码:
其中opt_first的代码如下:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="fill_parent" android:background="@drawable/ljo" android:alpha="0.7" android:gravity="fill_horizontal" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/nbf"> <ImageView android:id="@+id/iv_top" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ie_arrow_normal" android:onClick="finish_reback" android:layout_marginLeft="0dp" /> <TextView android:id="@+id/tv_top" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="加密方式选择" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:textColor="@android:color/holo_red_light"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@+id/iv_top" android:text="返回" android:textSize="20sp" /> </RelativeLayout> <ExpandableListView android:id="@+id/el_option" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="0dp" android:alpha="0.8" android:background="@drawable/beijingnihao" > </ExpandableListView> </LinearLayout>对于各种类的代码由于过于繁多,就不一一粘贴,如有需要的请私我。
二、测试
1、opt_first实现的界面如下所示:,其中有多种加密方式(实现的只有很少几种。。。)
2、进入代替加密技术进行加密
我们输入汉字,来自于网络的一段文字,然后点击加密,就能够转化为编码
3、在点击加密之后,能够看到加密的信息
如下图所示:
4、接着点击解密,就能够将信息还原
在这个小程序中,主要使用的是代替技术,即将很多字符进行代替以实现加密,当然还有几种其他的加密方式,有兴趣的可以交流。。。谢谢