Giter Site home page Giter Site logo

fhdalotaibi / cryptographyandroid Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 2.0 137 KB

CryptographyAndroid is a complements javax.crypto.Cipher and java.security.KeyStore to make it much easier to encrypt and decrypt your data. CryptographyAndroid stores cryptographic keys in the keyStore.

Java 100.00%
cryptographic-keys aes rsa keystore encryption decryption cryptography android security encryption-algorithms

cryptographyandroid's Introduction

CryptographyAndroid

CryptographyAndroid is a complements javax.crypto.Cipher and java.security.KeyStore to make it much easier to encrypt and decrypt your data. CryptographyAndroid stores cryptographic keys in the keyStore.

#RSA and AES CryptographyAndroid uses RSA and AES to cryptography your data.

  • AES is a symmetric cryptographic algorithm. symmetric means there is one key will be used for encryption and decryption. AES supports a block length of 128 bits and key lengths of 128, 192, and 256 bits.
    • AES in CryptographyAndroid library uses 128 bits as key length.
  • RSA is an asymmetric cryptographic algorithm. Asymmetric means that there are two different keys
    • Puplic key is used to encrypt messages, can be known to everyone.
    • Private key is used to decrypt messages, must be kept in a secure place.

#KeyStore KeyStore represents a storage facility for cryptographic keys and certificates. KeyStore stores cryptographic keys in a container to make it more difficult to extract from the device

#EXAMPLE:

    private String message = "i want to encrypt this message, it is very important message";
    private static final String MESSAGE_KEY_STORE_ALIAS = "keyStoreAliasForMessage";
    
    
    CryptographyManager cryptographyManager = new CryptographyManager(this);

        try {
            String cipherMessage = cryptographyManager.encrypt(message, MESSAGE_KEY_STORE_ALIAS);
            Toast.makeText(this, cipherMessage, Toast.LENGTH_SHORT).show();

            String decryptedMessage = cryptographyManager.decrypt(cipherMessage, MESSAGE_KEY_STORE_ALIAS);

            Toast.makeText(this, decryptedMessage, Toast.LENGTH_SHORT).show();

            Log.i(TAG, " Does decrypted message equals the original one : " 
            + Boolean.toString(message.equals(decryptedMessage)));

        } catch (KeyStoreException e) {
            e.printStackTrace();
        } catch (CertificateException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (NoSuchProviderException e) {
            e.printStackTrace();
        } catch (InvalidAlgorithmParameterException e) {
            e.printStackTrace();
        } catch (IllegalBlockSizeException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } catch (BadPaddingException e) {
            e.printStackTrace();
        } catch (NoSuchPaddingException e) {
            e.printStackTrace();
        } catch (UnrecoverableEntryException e) {
            e.printStackTrace();
        } catch (GeneralSecurityException e) {
            e.printStackTrace();
        }

#Download

<dependency>
<groupId>com.github.fhdalotaibi</groupId>
<artifactId>android-cryptography</artifactId>
<version>1.0.0</version>
<type>aar</type>
</dependency> 
compile 'com.github.fhdalotaibi:android-cryptography:1.0.0'

cryptographyandroid's People

Contributors

fhdalotaibi avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.