android 支付宝手势密码锁,Android仿支付宝手势密码解锁

ba1079da23fdaac9cb4254b4f3a4c228.pngStarting

创建手势密码可以查看 CreateGestureActivity.java 文件.

登陆验证手势密码可以看 GestureLoginActivity.java 文件.

Features

使用了 JakeWharton/butterknife butterknife

使用了 ACache 来存储手势密码

/**

* 保存手势密码

*/privatevoidsaveChosenPattern(ListLockPatternView.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<>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

98754251_2

Android订阅是探讨Android开发的公众号,分享最有价值的Android干货文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值