我需要像这样使用 URL 以加密格式传递数据,
http://localhost:8080/app/{encrypted_data}
那么,是否有任何编码器在编码中不包含正斜杠(/)?
请注意:我不想从编码数据中手动用另一个字符替换“/”。
................................................ ..................................................... .....................
已编辑: 来自 Oleg Estekhin 的评论 使用 Base64 URL 安全编码 也工作正常,我只是在这里添加一个示例。
示例:编码:
String str = "subjects?_d=1";
byte[] bytesEncoded = Base64.encodeBase64URLSafe((str.getBytes()));
解码:
Base64 decoder = new Base64(true);
byte[] decodedBytes = decoder.decode(new String(bytesEncoded));
System.out.println(new String(decodedBytes));
输出:
c3ViamVjdHM_X2Q9MQ
subjects?_d=1
最佳答案
关于Java:是否有任何编码器在数据加密期间不会包含正斜杠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24287462/