0

How to convert base64 to string in spring-boot(java). My private key in base64 format i want to convert it to string format. I don't know how to do this please help me to solve this problem.

KSMNOP k
  • 19
  • 4
  • 1
    [Java Base64 encode decode](https://stackoverflow.com/questions/19743851/base64-java-encode-and-decode-a-string), This may answer your question – Sakil Aug 25 '22 at 06:13
  • https://www.baeldung.com/java-base64-encode-and-decode – Stultuske Aug 25 '22 at 06:17
  • *My private key in base64 format i want to convert it to string format.* But (proper) private keys are *not* strings, which is *why* they are stored base64-encoded – g00se Aug 25 '22 at 11:20

1 Answers1

0

You need to understand encoding/decoding if you want to customize it but simply you can use Base64 class of Java to decode from Base64 to String. Given an example -

byte[] decode = Base64.getDecoder().decode("Your String");
String decodedString = new String(decode);

You can check java.util.Base64 class to find out more interesting thing.

Reference - https://www.baeldung.com/java-base64-encode-and-decode