base64

自定义/修改微信二维码样式

亡梦爱人 提交于 2020-01-14 20:03:05
在写项目的时候遇到的一个需求,登录和注册都可以通过扫描微信的二维码来实现,但是在做的时候发现微信有一些它自带的样式,并且无法通过CSS直接修改。 通过查微信的开发者文档发现是支持修改的 wxHandle ( ) { var obj = new WxLogin ( { id : "" , appid : , scope : "" , redirect_uri : '' , state : "" , style : "" , href : "xxx.css" //url地址 } ) ; } , 在实例化对象的 href属性中写入你的样式地址(例:把已经写好的样式放入xxx.css)即可,但是如果直接输入你的本地url地址会报错,所以需要把地址转换为https的。 解决方法 通过Node.js脚本转换地址,写一个node.js脚本 var fs = require ( 'fs' ) ; // function to encode file data to base64 encoded string function base64_encode ( file ) { // read binary data var bitmap = fs . readFileSync ( file ) ; // convert binary data to base64 encoded string

convert the file into base64 in elasticsearch for attachment

拟墨画扇 提交于 2020-01-14 04:10:32
问题 Actually, I want to change the file into base64 and attach with my elastic search JSON data. My Code is given below: curl -XDELETE "http://localhost:9200/test" curl -XPUT "http://localhost:9200/test/?pretty=1" -d ' { "mapping" : { "xmlfile" : { "properties" : { "attachment": { "type" : "attachment" } } } } }' curl -XPOST "http://localhost:9200/test/xmlfile?pretty=1" -d ' { "attachment" : '`base64 /path/filename | perl -pe 's/\n/\\n/g'`' }' curl -XGET "http://localhost:9200/test/xmlfile/

convert the file into base64 in elasticsearch for attachment

末鹿安然 提交于 2020-01-14 04:10:15
问题 Actually, I want to change the file into base64 and attach with my elastic search JSON data. My Code is given below: curl -XDELETE "http://localhost:9200/test" curl -XPUT "http://localhost:9200/test/?pretty=1" -d ' { "mapping" : { "xmlfile" : { "properties" : { "attachment": { "type" : "attachment" } } } } }' curl -XPOST "http://localhost:9200/test/xmlfile?pretty=1" -d ' { "attachment" : '`base64 /path/filename | perl -pe 's/\n/\\n/g'`' }' curl -XGET "http://localhost:9200/test/xmlfile/

How to encode base64 in Delphi 6? [duplicate]

怎甘沉沦 提交于 2020-01-14 02:35:05
问题 This question already has answers here : Binary to Base64 (Delphi) (2 answers) Closed 6 years ago . I need to encode a pdf document to base64 in Delphi6. Can anyone help me? 回答1: You can use the EncdDecd unit that is supplied with Delphi. The function you need is EncodeStream . You simply need to create two streams, one for input and one for output. If you are working with files then you should create TFileStream instances. Once you have your two file streams created, all you need is:

php与base64图片

这一生的挚爱 提交于 2020-01-13 20:07:16
1、优缺点 1. 优点 (1)base64格式的图片是文本格式,占用内存小,转换后的大小比例大概为1/3,降低了资源服务器的消耗; (2)网页中使用base64格式的图片时,不用再请求服务器调用图片资源,减少了服务器访问次数。 2. 缺点 (1)base64格式的文本内容较多,存储在数据库中增大了数据库服务器的压力; (2)网页加载图片虽然不用访问服务器了,但因为base64格式的内容太多,所以加载网页的速度会降低,可能会影响用户的体验。 (3)base64无法缓存,要缓存只能缓存包含base64的文件,比如js或者css,这比直接缓存图片要差很多,而且一般HTML改动比较频繁,所以等同于得不到缓存效益。 3.综合 因为base64的使用缺点,所以一般图片小于10kb的时候,我们才会选择使用base64图片,比如一些表情图片,太大的图片转换成base64得不偿失。当然,极端情况极端考虑。 2、使用 一: 图片转base64编码 /*图片转换为 base64格式编码*/ $img = 'uploads/01.png'; $base64_img = base64EncodeImage($img); echo '<img src="' . $base64_img . '" />'; function base64EncodeImage ($image_file) { $base64

Restoring a numpy array representing an image after base64 encoding

空扰寡人 提交于 2020-01-13 18:01:05
问题 Using base64 encoding on images gives the opportunity to fully restore the image to its original shape, with all its dimension (2D, RGB) without knowing the resolutions directly - they are stored inside the base64 information However, when I have a numpy array representing an image like: test_image = np.random.rand(10,10,3) and then put it into base64 with: b64_test_image = base64.b64encode(test_image) I am able to get back to the content of the array with: decoded = base64.b64decode(b64_test

AES中ECB模式的加密与解密(Python3.7)

痞子三分冷 提交于 2020-01-13 14:04:32
本文主要解决的问题 本文主要是讲解AES加密算法中的ECB模式的加密解密的Python3.7实现。具体AES加密算法的原理这里不做过多介绍,想了解的可以参考文末的参考链接。 主要解决了两个问题: 在Python3.7版本下,所依赖包的安装问题 。(有一些博客时间久远,其中所提到的模块并不适用于Python3.7) 因为Python版本的问题,其他博客在基于Python3.6下的代码在Python3.7下并不能运行的问题 。 背景介绍 在爬虫项目中遇到,某些网站的账号、密码采用了AES的ECB模式进行了加密。 # 加密前的数据 123456asd # 加密后的数据 3cfeba82c31b6635e8fb085e04529e74 # 密钥 8NONwyJtHesysWpM 使用 在线AES加密解密、AES在线加密解密 ,进行尝试。 经过测试发现,在 AES 加密的 ECB模式 ,填充为 pkcs7padding ,数据块为 128位 ,输出格式为 hex 时,得到自己想要的结果。 (这里可以可以根据密文的格式进行判断输出的格式, 一般密文以==结尾的输出格式为base64 ,否则为hex格式) 问题1:Crypto模块安装报错 pip 安装 pycrypto模块,抛如下错误: error: command 'C:\\Program Files (x86)\\Microsoft

How can I convert a UUID to base64?

允我心安 提交于 2020-01-13 12:14:07
问题 I want to take type UUID and output it in a Base64 encoded format, however given the input methods on Base64 and outputs on UUID how to accomplish this doesn't seem obvious. update though not an explicit requirement for my use case, it would be nice to know if the method used uses the raw UUID (the 128 bits that a UUID actually is) of the UUID, as the standard hex encoding does. 回答1: First, convert your UUID to a byte buffer for consumption by a Base64 encoder: ByteBuffer uuidBytes =

Trouble loading Base64 string to canvas

↘锁芯ラ 提交于 2020-01-13 09:46:49
问题 I'm trying to load a Base64 string from my database to a canvas. I obtained this string from doing the reverse method: I saved it to my database after drawing on a canvas. So, now I want to load it back onto another canvas. I have tried this code which I picked up on the web and somewhere else here on StackOverflow but it doesn't seem to work. <script type="text/javascript"> $(document).ready(function(){ var canvas = document.getElementById("loading_canvas"); var ctx = canvas.getContext("2d")

Converting to Base64 in JavaScript without Deprecated 'Escape' call

蓝咒 提交于 2020-01-13 09:26:09
问题 My name is Festus. I need to convert strings to and from Base64 in a browser via JavaScript. The topic is covered quite well on this site and on Mozilla, and the suggested solution seems to be along these lines: function toBase64(str) { return window.btoa(unescape(encodeURIComponent(str))); } function fromBase64(str) { return decodeURIComponent(escape(window.atob(str))); } I did a bit more research and found out that escape() and unescape() are deprecated and should no longer be used. With