Amr*_*rut 5 java encryption spring spring-cloud
我们已经使用 Spring 云配置外部化了我们的应用程序配置。我们还使用加密 API 在纯文本密码进入 yaml 属性文件之前对其进行加密。
我正在努力为下游系统加密密码,该密码最后具有特殊字符。不知何故,云配置加密 API 忽略了这一点。当您使用解密 API 解密密码时,您会得到纯文本,最后没有特殊字符。
我正在使用 curl 来调用 API -
curl 10.102.82.1:11901/encrypt -d AXIzFDH4XZA=
Run Code Online (Sandbox Code Playgroud)
出于某种原因,纯文本中间的特殊字符可以正常工作,但是如果最后有它,那么它会被忽略。可能这个密码已经被散列了,但我仍然很想知道如何处理这个问题。
设置明确的 Content-Type: text/plain 以确保 curl 在有特殊字符时正确编码数据
curl -H "Content-Type: text/plain" 10.102.82.1:11901/encrypt -d AXIzFDH4XZA=
Run Code Online (Sandbox Code Playgroud)
这是在云配置文档中指定的,在页面上查找提示 - http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_encryption_and_decryption
小智 5
我在密码中遇到了 \'}\' 的问题,解决这个问题的唯一方法是在密码前加上 {plain} 前缀,如下所示:
\n\nexport PASSWORD=$(curl -X POST --data-urlencode "{plain}adfadf%273}*+\xe2\x80\x9d http://username:password@localhost:8888/encrypt)\n\ncurl http://username:password@localhost:8888/decrypt -d {cipher}$PASSWORD\n
Run Code Online (Sandbox Code Playgroud)\n