Android仿支付宝手势密码解锁功能
作者:lijiao 发布时间:2023-02-14 09:06:46
标签:Android,支付宝,手势密码
Starting
创建手势密码可以查看 CreateGestureActivity.java 文件.
登陆验证手势密码可以看 GestureLoginActivity.java 文件.
Features
使用了 JakeWharton/butterknife butterknife
使用了 ACache 来存储手势密码
/**
* 保存手势密码
*/
private void saveChosenPattern(List<LockPatternView.Cell> cells)
{
byte[] bytes = LockPatternUtil.patternToHash(cells);
aCache.put(Constant.GESTURE_PASSWORD, bytes);
}
Warning: 使用 ACache 类保存密码并不是无限期的. 具体期限可以查看 ACache 类.
使用了 SHA 算法保存手势密码
/**
* Generate an SHA-1 hash for the pattern.
* Not the most secure, but it is at
* least a second level of protection. First level is that the file is in a
* location only readable by the system process.*
* @param pattern
* @return the hash of the pattern in a byte array.
*/
public static byte[] patternToHash(List<LockPatternView.Cell> pattern)
{
if (pattern == null) {
return null;
} else {
int size = pattern.size();
byte[] res = new byte[size];
for (int i = 0; i < size; i++) {
LockPatternView.Cell cell = pattern.get(i);
res[i] = (byte) cell.getIndex();
}
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-1");
return md.digest(res);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return res;
}
}
}
可以开启震动模式,当选中一个圈的时候,手机会震动
/** * Set whether the view will use tactile feedback.
*If true, there will be
* tactile feedback as the user enters the pattern.
* @param tactileFeedbackEnabled Whether tactile feedback is enabled
*/
public void setTactileFeedbackEnabled(boolean tactileFeedbackEnabled) {
mEnableHapticFeedback = tactileFeedbackEnabled;
}
可以开启绘制路径隐藏模式
/**
* Set whether the view is in stealth mode. If true, there will be no
* visible feedback as the user enters the pattern.
* @param inStealthMode Whether in stealth mode.
*/public void setInStealthMode(boolean inStealthMode) {
mInStealthMode = inStealthMode;
}
Example


猜你喜欢
- 实体对象之间相互传值,如:VO对象的值赋给Entity对象,是代码中常用功能,如果通过get、set相互赋值,则很麻烦,借助工具类BeanU
- 文章来源:csdn 作者:chensheng913对于Java语言,最体贴的一项设计就是它并没有打算让人们为了写程序而写程序——人们也需要考
- java遍历json字符串,取得相应KV值时,各种麻烦,比如将json中的list取出来转为JSONArray,再将list中的object
- 本文实例讲述了C#实现随机数产生类。分享给大家供大家参考。具体分析如下:这个类主要扩展的random的使用,对一个经常需要使用的随机数生成进
- 一、@EnableTransactionManagement工作原理开启Spring事务本质上就是增加了一个Advisor,但我们使用 @E
- 本文实例为大家分享了闪耀字体效果的具体代码,供大家参考,具体内容如下import android.content.Context;impor
- 单链表:insertFirst:在表头插入一个新的链接点,时间复杂度为O(1)deleteFirst:删除表头的链接点,时间复杂度为O(1)
- 在派生类中引发基类事件以下简单示例演示了在基类中声明可从派生类引发的事件的标准方法。此模式广泛应用于 .NET Framework 类库中的
- 前言延迟初始化 是一种将对象的创建延迟到第一次需要用时的技术,换句话说,对象的初始化是发生在真正需要的时候才执行,值得注意的是,术语&nbs
- 本文实例展示了WinForm实现为TextBox设置水印文字功能,非常实用的技巧,分享给大家供大家参考。关键代码如下:using Syste
- 1、Date日期输出可读性较差Date date = new Date();System.out.println(date);打印输出的结果
- 首先我们看看为什么添加Watch。ZooKeeper是用来协调(同步)分布式进程的服务,提供了一个简单高性能的协调内核,用户可以在此之上构建
- 本文实例讲述了C#使用Ado.Net更新和添加数据到Excel表格的方法。分享给大家供大家参考。具体分析如下:微软NET提供了一个交互的方法
- 学习初衷:在工作实际开发过程中,原有的安卓控件已不能满足实际的功能需求,而且有些应用还需要一些独特的展示效果,这时就需要自定义控件来定制控件
- 前言由于android M的popupwindow与之前版本不一致,笔者找不到能够代码监听物理返回键的方式,故另寻方式实现筛选菜单。5.0及
- 1、通过查找API文档:2、Map.Entry是一个接口,所以不能直接实例化。3、Map.entrySet( )返回的是一个collecti
- 日常的Rest服务开发我都会首选SpringBoot,因为它本身的易用性以及自带的各种方便功能、生态等,今天就简单讲一下如何将Spring
- 本文分析了Android实现换肤的两种思路。分享给大家供大家参考,具体如下:这里来了解换肤实现及不同方案的差异和使用场合。一、从功能上划分1
- C# Linq获取两个List或数组的差集交集List<int> list1 = newList<int>();li
- 之前在开发一个程序,希望能够通过属性名称读取出属性值,但是由于那时候不熟悉反射,所以并没有找到合适的方法,做了不少的重复性工作啊!然后今天我