Tell me, please, how to obtain a hash in accordance with GOST R 34.11-94 from the specified byte[] .

For example, there is a certain text.

 String text = "abcd"; //Из этого получаю input byte[] input = text.getBytes(); 

then i need from byte[] get a hash.

    1 answer 1

    Through the native Java mechanism:

     Security.addProvider(new BouncyCastleProvider()); //регистрируем провайдера, можно выполнить где-нибудь статически byte[] text="abcd".getBytes(); MessageDigest md = MessageDigest.getInstance("GOST3411",BouncyCastleProvider.PROVIDER_NAME); //второй параметр можно опустить byte[] resultHash = md.digest(text); 

    Directly via BC :

     byte[] text="abcd".getBytes(); GOST3411.Digest md = new GOST3411.Digest(); byte[] resultHash = md.digest(text);