Encryption


Source link: https://github.com/simbiose/Encryption

Encryption

Encryption is a simple way to encrypt and decrypt strings on Android and Java project.

How to use

1º Add JitPack to your build file

allprojects {

repositories {

  ...
  maven {
 url 'https://jitpack.io' 
}

}
 
}
 

2º Add the gradle dependency

compile 'com.github.simbiose:Encryption:2.0.1' 

3º Get an Encryption instance

String key = "YourKey"; String salt = "YourSalt"; byte[] iv = new byte[16]; Encryption encryption = Encryption.getDefault(key, salt, iv);
 

4º Encrypt your text

String encrypted = encryption.encryptOrNull("Text to be encrypt");
 

5º Decrypt your text

String decrypted = encryption.decryptOrNull(encrypted);
 

Custom usage

You can use you own builder

Encryption encryption = new Encryption.Builder()

  .setKeyLength(128)

  .setKey("YourKey")

  .setSalt("YourSalt")

  .setIv(yourByteIvArray)

  .setCharsetName("UTF8")

  .setIterationCount(1)

  .setDigestAlgorithm("SHA1")

  .setBase64Mode(Base64.DEFAULT)

  .setAlgorithm("AES/CBC/PKCS5Padding")

  .setSecureRandomAlgorithm("SHA1PRNG")

  .setSecretKeyType("PBKDF2WithHmacSHA1")

  .build();
 

See more on Examples folder, there is an Android, a Java and a Kotlin project.

FAQ

  • What is Encryption library?
    • Encryption library is an Open Source library to help encryption routines in Android and Java applications, our target is to be simple and secure.
  • What is the "IV", what should be my yourByteIvArray
    • Encryption 1.2+ uses by default the AES algorithm in CBC mode, so to encrypt and decrypt works you should have the same key and the same IV byte array to encrypt and to decrypt. An example of IV is byte[] iv = { -89, -19, 17, -83, 86, 106, -31, 30, -5, -111, 61, -75, -84, 95, 120, -53 } ; like you can see, 16 bytes in a byte array. So if you want to use this library I recommend you create you own IV and save it 💾.
  • I Don't like null returns when errors occurs, what to do to handle errors?
    • You have the power to handle the exceptions, instead of uses encryptOrNull method just uses the encrypt method. The same for the decryptOrNull, just uses the decrypt method.
  • I'm getting problems with main thread, what to do?
    • Encrypt routines can take time, so you can uses the encryptAsync with a Encryption.Callbackto avoid ANR'S. The same for decryptAsync
  • I'm an older user, version 1.4 or less, what to do to update Encrypt to version 2.+?
    • The library has changed the default iteration count from 65536 to 1, it improve the performance, if you have a code using the old version or if you prefer to use a big iteration count you just need to use a custom builder instead of get the default builder and set the iteration count you want
    • As far as the library uses 1 as default iteration count we do not need anymore the getLowIteration and it was removed from project, if you use it you can just change to getDefault
    • MIT is the project license so feel free to use it 🎉
  • I'm a very older user, version 1.1 or less, what to do to update Encrypt to version 1.2+?
    • The library has several changes in his structure in version 1.2, both in algorithm and in code usage, so if you are an older user you need migrate the encrypted stuff or configure the Builder manually to the same parameters used in version 1.1 and olds.

Want to contribute?

Fell free to contribute, We really like pull requests

Third part

  • Copyright (C) 2010 The Android Open Source Project, applied to:
    • Base64 (third.part.android.util.Base64) original comes from here

Resources

This project helps to use elliptic curve cryptography (ECC) with Curve25519.

RippleDecoratorView is a widget library with a view used to wrap any of your layouts. It allows you, for any touch, to add animations effects such as: ripple stroke, ripple fill, highlight, and zoom. These animations come with a configurable fade-in, fade-out timeline.

Flickable ImageView for Android. It is like a view of twitter's detail image.

Android Texture VideoView having a variety of scale types like the scale types of ImageView.

The PhotoCrop is an image cropping tool. It provides a way to set an image in XML and programmatically, and displays a resizable crop window on top of the image. Calling the method getCroppedImage() will then return the Bitmap marked by the crop window.

Ghost Log is an Android application that displays the device logcat buffer in a system overlay window.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes