【问题标题】:How to decrypt password in android?如何在android中解密密码?
【发布时间】:2020-05-20 08:24:24
【问题描述】:

我正在开发一个使用AccessibilityService android 类的项目。

通过AccessibillityService ( TYPE_VIEW_TEXT_CHANGED )获取密码。

但是密码是点...........

如何将这些点转换为文本字符串?

是否有任何可能的解密解决方案?

谢谢

【问题讨论】:

  • 我怀疑你能做到这一点,通过无障碍服务检索密码似乎不太安全,但我可能错了:)

标签: android passwords accessibility password-protection accessibilityservice


【解决方案1】:
  • 使用 KeyGenerator 为 DESede 创建一个密钥对象 算法。
  • 创建一个实现 DESede 转换的密码,使用 getInstance(String algorithm) API 方法。

这里是代码:-

public class Main {

    static String algorithm = "DESede";

    public static void main(String[] args) throws Exception {

        Key symKey = KeyGenerator.getInstance(algorithm).generateKey();

        Cipher c = Cipher.getInstance(algorithm);

        byte[] encryptionBytes = encryptF("texttoencrypt", symKey, c);

        System.out.println("Decrypted: " + decryptF(encryptionBytes, symKey, c));
    }

    private static byte[] encryptF(String input, Key pkey, Cipher c) throws InvalidKeyException, BadPaddingException,

            IllegalBlockSizeException {

        c.init(Cipher.ENCRYPT_MODE, pkey);

        byte[] inputBytes = input.getBytes();

        return c.doFinal(inputBytes);
    }

    private static String decryptF(byte[] encryptionBytes, Key pkey, Cipher c) throws InvalidKeyException,

            BadPaddingException, IllegalBlockSizeException {

        c.init(Cipher.DECRYPT_MODE, pkey);

        byte[] decrypt = c.doFinal(encryptionBytes);

        String decrypted = new String(decrypt);

        return decrypted;
    }
}

【讨论】:

  • 感谢您的回复。在解密方法中,pkey参数代表什么?
  • 我的意思是我们要解密到哪里传递它?
猜你喜欢
  • 2016-06-12
  • 2014-10-17
  • 2014-04-20
  • 2012-02-03
  • 2017-05-05
  • 1970-01-01
  • 1970-01-01
  • 2018-07-24
  • 1970-01-01
相关资源
最近更新 更多