Java:有没有在数据加密期间不包含正斜杠的编码器?

Java:有没有在数据加密期间不包含正斜杠的编码器?,java,encryption,encoding,Java,Encryption,Encoding,我需要用这样的URL以加密格式传递数据, http://localhost:8080/app/{加密的_数据} 那么,是否有任何编码器在编码中不包含正斜杠(/)呢 请注意:我不想用编码数据中的另一个字符手动替换“/” 编辑:来自的使用Base64 URL安全编码的评论也很好,我只是在这里添加一个示例 示例:编码: String str = "subjects?_d=1"; byte[] bytesEncoded = Base64.encodeBase64URLSafe((str.getByte

我需要用这样的URL以加密格式传递数据,
http://localhost:8080/app/{加密的_数据}

那么,是否有任何编码器在编码中不包含正斜杠(/)呢

请注意:我不想用编码数据中的另一个字符手动替换“/”

编辑:来自的使用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
解码:

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
输出:

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

例如:


为了简化问题,您可以使用{encrypted_data}来简化问题。您是想隐藏数据还是想验证数据是否已更改?不,要求不是使用“?”或作为URL参数传递。其次,我进行编码是因为我在{encryped_data}上传递了一个URL,它同样包含一些“/”:数据这里有URL安全的Base64变体,大多数Base64库提供了一种重载的编码/解码方法,可用于此类变体。例如,选中。@OlegEstekhin yep。。它正在工作。。。谢谢老板!!:)还有一个Base64变体,其中替换了
+
/
。看见特别是在Java8中,现在