Giter Site home page Giter Site logo

encrypt-java's Introduction

Encrypt-java

  • Features: encrypt, decrypt, hash code, md5
  • Platform: Android, PC
  • Encrypt algorithm: DES, AES
  • Hash algorithm: MD2, MD5, SHA1, SHA256...

Usage

Encrypt

    String content = "Test content";
    String password = "password";
    String encrypted = EncryptUtil.encrypt(content, password);

Decrypt

    String encrypted = "c73ba17d16f44b8c9e2232200aad11b81070740774d468892c79aca4ac96e5d3";
    String password = "password";
    String decrypted = EncryptUtil.decrypt(encrypted, password);

hash value (md5, sha1, sha256...)

    EncryptUtil.md5("Test content");
    // or
    EncryptUtil.digest("Test content", EncryptUtil.ALGORITHM.MD5);
    EncryptUtil.digest("Test content", EncryptUtil.ALGORITHM.SHA256);

Test sample

    String content = "Test content, 测试测试";
    String password = "password!@#";
    System.out.println("content:" + content + "\n");

    String encrypted = EncryptUtil.encrypt(content, password);
    System.out.println("AES encrypt:" + encrypted);
    System.out.println("AES decrypt:" + EncryptUtil.decrypt(encrypted, password) + "\n");

    encrypted = EncryptUtil.encrypt(content, password, EncryptUtil.ALGORITHM.DES);
    System.out.println("DES encrypt:" + encrypted);
    System.out.println("DES decrypt:" + EncryptUtil.decrypt(encrypted, password, EncryptUtil.ALGORITHM.DES) + "\n");

    System.out.println("md5 hash:" + EncryptUtil.md5(content));
    System.out.println("sha256 hash:" + EncryptUtil.digest(content, EncryptUtil.ALGORITHM.SHA256));

encrypt-java's People

Contributors

taolin-cvte avatar taolin2107 avatar

Watchers

 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.