droidchef / android-lockpattern

Automatically exported from code.google.com/p/android-lockpattern
Apache License 2.0
0 stars 0 forks source link

How to get Patten saved in shared preferences in decrypted form #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Register the CustomeEnrypter Class, which implemented the IEncrypter 
interface. version 3.0.3
2. Decrypt Method Issued Exception 
3.//My Implementation of IEncrypter 
@Override
    public List<Cell> decrypt(Context context, char[] encryptedPattern) {
        // TODO Auto-generated method stub
        Log.i("LOCK-PATERN-DECRYPTED",new String(encryptedPattern));
        return LockPatternUtils.stringToPattern(new String(encryptedPattern));

    }
    @Override
    public char[] encrypt(Context context, List<Cell> pattern) {
        // TODO Auto-generated method stub
        CRC32 c = new CRC32();
        c.update(LockPatternUtils.patternToSha1(pattern).getBytes());
        String Data = String.format("%08x", c.getValue());

        Log.i("LOCK-PATERN-ENCYPTED in LONG",c.getValue()+"");
        Log.i("LOCK-PATERN-ENCYPTED",Data);

        return Data.toCharArray();
    }

What is the expected output? What do you see instead?
I want to get the Entered pattern Lock in number format. e.g if USER make lock 
with 123654 , when user forget the pattern he has to press forget pattern 
button, that initialize ForgetPattenActivity, in this Activity i have to Find 
the SAVED pattern.

What version of the product are you using? On what operating system?
Latest Version 3.0.3
on NEXUS 4 with ANDROID 4.4.2

Please provide any additional information below.

I have also Registerd the IEncrypter . But that class give me every time 8 
digit number, 
WHAT i am thinking pattern is saving in some encypted form and i donot know how 
to decrypt it in number form that has entered by user. in other words i have to 
display the forget pattern to user 

Original issue reported on code.google.com by mian.mub...@gmail.com on 9 Jan 2014 at 10:52

GoogleCodeExporter commented 9 years ago
Hi,

In your encrypt() method, first you calculate the pattern's SHA1, then you 
calculate the CRC32 of that SHA1. So as far as I know, you can't decrypt it to 
original pattern in method decrypt().

If you look at LockPatternView.java, you could see that Cell has a getId() 
method. The ID starts from 0. To encrypt the pattern to a list of IDs, you can 
consider using that method. Please note that for security, you should use 
encryption / decryption with a cipher (such as AES...). I'm not good at cipher, 
but Google gives me some examples:

- 
http://techie-experience.blogspot.com/2012/10/encryption-and-decryption-using-ae
s.html
- http://www.code2learn.com/2011/06/encryption-and-decryption-of-data-using.html

Hope you could manage to solve it  :-)

Original comment by haibison...@gmail.com on 9 Jan 2014 at 11:26

GoogleCodeExporter commented 9 years ago
I've updated the wiki page Encryption. It shows you the implementation of 
IEncrypter in the demo app. Please have a look...

- https://code.google.com/p/android-lockpattern/wiki/Encryption

Original comment by haibison...@gmail.com on 9 Jan 2014 at 11:33

GoogleCodeExporter commented 9 years ago
That Is Much Easy to understand ... Thanks, Now I can implement My Custom
any type Encryption and can decrypt. But Basic Numbers are clear to get.
Thanks.

*RegardsMuhammad Mubasher UsmanSoftware Engineer ( Lead )Iterative
Technologies Pvt.Islamabad , Pakistan*

Original comment by mian.mub...@gmail.com on 10 Jan 2014 at 2:58

GoogleCodeExporter commented 9 years ago

Original comment by haibison...@gmail.com on 10 Jan 2014 at 6:02

GoogleCodeExporter commented 9 years ago

Original comment by haibison...@gmail.com on 11 Jan 2014 at 1:47