Java Hash String hashAlgToId(String hashAlg)

Here you can find the source of hashAlgToId(String hashAlg)

Description

hash Alg To Id

License

Open Source License

Declaration

public static int hashAlgToId(String hashAlg) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w  . j  ava 2 s . com*/
Blue Crystal: Document Digital Signature Tool
Copyright (C) 2007-2015  Sergio Leal
    
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.
    
You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    protected static final int ALG_SHA1 = 0;
    protected static final int ALG_SHA224 = 1;
    protected static final int ALG_SHA256 = 2;
    protected static final int ALG_SHA384 = 3;
    protected static final int ALG_SHA512 = 4;

    public static int hashAlgToId(String hashAlg) {

        int hashId = 0;

        if (hashAlg.compareToIgnoreCase("SHA1") == 0) {
            hashId = ALG_SHA1;
        } else if (hashAlg.compareToIgnoreCase("SHA224") == 0) {
            hashId = ALG_SHA224;
        } else if (hashAlg.compareToIgnoreCase("SHA256") == 0) {
            hashId = ALG_SHA256;
        } else if (hashAlg.compareToIgnoreCase("SHA384") == 0) {
            hashId = ALG_SHA384;
        } else if (hashAlg.compareToIgnoreCase("SHA512") == 0) {
            hashId = ALG_SHA512;
        }
        return hashId;
    }
}

Related

  1. hash(String str, int offset)
  2. hash(String string)
  3. hash(String string, int length)
  4. hash(String strPlain)
  5. hash32(String data)
  6. hashArrayToString(int a[])
  7. hashbang(final String historyToken)
  8. hashcode(String name)
  9. hashCode(String s)