how decode the encodeBase64URLSafeString hashkey

Viewed 149

How to decode the encoded string using encodeBase64URLSafeString.

code: KeyGenerator generator = KeyGenerator.getInstance("HmacSHA1");

SecretKey key = generator.generateKey();

encodedKey = Base64.encodeBase64URLSafeString(key.getEncoded());

output: E6S9fTfMfAgkNVodHLDmxz-2M_g90bpFztW6GB7-7VcGfyOkugESxjNx1CGf5taJDXz895uWAF5ubPnaqhe4nw

can anyone please help me on how to decode the output string which is in encrypted format?

Tried using decryption with jasypt library but it is throwing bad input error.

1 Answers

You have to decode it with the same library you have used for encoding org.apache.commons.codec.binary.Base64;

This is working for me

System.out.println(Base64.decodeBase64("E6S9fTfMfAgkNVodHLDmxz-2M_g90bpFztW6GB7-7VcGfyOkugESxjNx1CGf5taJDXz895uWAF5ubPnaqhe4nw"));

enter image description here

Keep in mind Decode/Decrypt are 2 different things. Here you have encoded it, in your last process, so you have to decode it.

Related