Giter Club home page Giter Club logo

hashchecker's Introduction

HashChecker

A simple hash calculator
一个简单的 Hash 计算应用

Feel free to do anything you like, for example, fork it and change it.
随便对待它吧,你可以Fork并自行修改 。

Now, you are able to check a file in other apps(after 1.4), or get a value(after 1.5). 现在,你可以在其它应用中检查文件正确性(1.4之后),或者获取一个值(1.5之后)。

HOW TO USE HASHCHECKER'S API IN OTHER APPS - FAST TUTORIAL

Step 0
You should have a file and a value to compare with(optional). 你需要有一个文件和一个用于比对的值(可选)。 Of course, an Android device with this app.
当然还有,一台装有 HashChecker 的 Android 设备。

Step 1
Create an Intent and turn action in it.
实例化一个 Intent 并向内放入 action 。
For example,
比如:

…
Intent intent = new Intent();
intent.setAction("net.rachel030219.hashchecker.action.COMPARE_MD5");    // You can just replace "COMPARE" with "CALCULATE" to calculate and get the value
…

Optional action list is rolled out.
可选的 action 列表已放出。

Step 2
Turn in extra and set type.
放入数据,设置类型。

…
intent.putExtra("net.rachel030219.hashchecker.extra.FILE",file);
intent.putExtra("net.rachel030219.hashchecker.extra.VALUE",value);    // No need if you choose "CALCULATE"
intent.setType("image/png");
…

For more information, please look up API DOC below.
欲获得更多信息,请查阅下面的 API 文档。

Step 3
Just send it out!
发出来吧!

…
try {
    startActivityForResult(intent,REQUEST_CODE);
} catch (android.content.ActivityNotFoundException e) {
    // This means the user has not installed HashChecker
}
…
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data){
    if (requestCode == REQUEST_CODE){
        switch(resultCode) {
            case 100:
                // Do something…
                break;
            case 10:
                // Do something…
                break;
            default:
                // Must be something happened. I suggest to ignore this section in your code.
                break;
        }
    }
}

And…
That's all! So easy, right?
没了!很简单,不是吗?

若有需要,请参阅 APIExample

API DOC

Comparing Actions

  1. net.rachel030219.hashchecker.action.COMPARE_MD5 Calculate and compare file's MD5
    计算、比较 MD5 值

  2. net.rachel030219.hashchecker.action.COMPARE_SHA1 The same, SHA1
    同理, SHA1

  3. net.rachel030219.hashchecker.action.COMPARE_SHA256 Again, SHA256 同理x2, SHA256

  4. net.rachel030219.hashchecker.action.COMPARE_SHA384 Againn, SHA384 同理x3, SHA384

  5. net.rachel030219.hashchecker.action.COMPARE_SHA512 Againnn, SHA512 同理x4, SHA512

  6. net.rachel030219.hashchecker.action.COMPARE_CRC32_HEX Againnnn, CRC32, remember to turn in a hexadecimal value 同理x5, CRC32 ,记得传入一个十六进制值

  7. net.rachel030219.hashchecker.action.COMPARE_CRC32_DEC Againnnnn, CRC32, you need also to turn in a String value, although decimal CRC32 can be long value
    同理x6, CRC32 ,你同样需要传入一个 String 值,即使十进制的 CRC32 可以用 long 存储

Calculating Actions

0. `net.rachel030219.hashchecker.action.COMPARE_MD5`
    Calculate and compare file's MD5
    计算 MD5 值

1. `net.rachel030219.hashchecker.action.COMPARE_SHA1`
    The same, SHA1
    同理, SHA1

2. `net.rachel030219.hashchecker.action.COMPARE_SHA256`
    Again, SHA256
    同理x2, SHA256

3. `net.rachel030219.hashchecker.action.COMPARE_SHA384`
    Againn, SHA384
    同理x3, SHA384

4. `net.rachel030219.hashchecker.action.COMPARE_SHA512`
    Againnn, SHA512
    同理x4, SHA512

5. `net.rachel030219.hashchecker.action.COMPARE_CRC32_HEX`
    Againnnn, CRC32 in hexadecimal
    同理x5, CRC32 十六进制

6. `net.rachel030219.hashchecker.action.COMPARE_CRC32_DEC`
    Againnnnn, CRC32 in decimal
    同理x6, CRC32 十进制

Extras

  1. net.rachel030219.hashchecker.extra.FILE - java.io.File
    File, just the one you want to do with.
    文件,就是你想计算的那个。

  2. net.rachel030219.hashchecker.extra.VALUE - java.lang.String
    The value which will be compared with the result.
    最后会和结果进行对比的值。
    Not required after 1.5 and when calculating.
    在 1.5 之后,计算值时不被要求。
    BTW, HashChecker will auto change its case.
    另外, HashChecker 会自动改变其大小写。

And the result…

~~ As what I said, HashChecker is unable to return a String value, so its API is used for only comparing. ~~ ~~ 就像我所说的那样, HashChecker 不能回传 String 值,所以它的 API 只用来比较。 ~~ ~~ And so, you need to check what it returns. ~~ ~~ 那么,就需要检查它所返回的值。 ~~

When you choose COMPARE, you'll have to check the result. 当选择 COMPARE 的时候,需要检查返回值以判断结果是否如预期。 There are only two cases. 只有两种情况。

  1. 100 - java.lang.Integer
    In this case, result matches what you have turned in. Congratulations!
    这种情况下,结果与你所传入的值匹配。恭喜!
  2. 10 - java.lang.Integer In this case, result does not match what you have turned in. Maybe you need to check the file.
    这种情况下,结果与你所传入的值不相符。可能得查查这个文件了。
  3. And other values?
    Umm… I don't know either. Maybe your user did something that impolite to HashChecker. So if you got this case, you can just retry. (F***ing your user is also OK)
    唔…我也不知道了。可能你的用户做了某些对 HashChecker 不礼貌的事情。所以如果你发现出现这种奇葩事情,重来就行。 (对你的用户表示礼貌也行我不反对)

Or, you choose CALCULATE, then please get the value out from the extra. 或者如果选择了 CALCULATE ,就请从 Extra 中取出值。

  1. 100 - java.lang.Integer & net.rachel030219.hashchecker.extra.RESULT_VALUE This is just the value you are looking for. 这就是你想要的那个值。

Get it on Google Play

欢迎关注 Telegram Channel / Twitter

Screenshots:
Screenshot1 Screenshot2


LICENSE

   Copyright 2017 Rachel030219

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

hashchecker's People

Contributors

rachel030219 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.