Clojure base64编码 [英] Clojure base64 encoding

查看:160
本文介绍了Clojure base64编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一些简单的string - > base64。使用较旧的base64.encode-str它很简单(并且听起来更clojure,但较新的 clojure.data.codec.base64 需要输入和输出流,似乎所以,有一个字符串,得到一个base64编码数组的方式是什么?谢谢

解决方案

您可以使用 encode 函数并传递字节数组:

 (encode(.getBytesHello world!))


I want something as simple as "string" -> base64. With the older base64.encode-str it was easy (and sounded "more clojure", but the newer clojure.data.codec.base64 requires input and output streams and seems an ugly wrapper around Java way of doing things.

So, what is the way, having a string, to get a base64 encoded array? Thanks

解决方案

You can use encode function and pass array of bytes:

(encode (.getBytes "Hello world!"))

这篇关于Clojure base64编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆