Base64 encoded data maximum size

后端 未结 4 1984
不思量自难忘°
不思量自难忘° 2021-02-09 11:51

I have a security mechanism that implements symmetric algorithm RijndaelManaged. I managed to find information what is the maximum size of encrypted data using

4条回答
  •  情话喂你
    2021-02-09 12:37

    In Java:

    byte[] bytes = new byte[128];
    int base64Length = bytes.length / 3 * 4; // Strictly integer division
    if (bytes.length % 3 != 0)
    {
        base64Length += 4; // Extra padding characters will be added
    }
    System.out.println(bytes.length + " bytes will be encoded in " + base64Length + " characters.");
    

    So, where the input bytes.length == 128, the output will be base64Length == 172 characters.

提交回复
热议问题