base64

Generate an image of a div and Save as

喜欢而已 提交于 2020-01-22 09:30:29
问题 I'd like to create an input button "Save image" that : take a screen shot of a div ask to "Save as" on the user's computer I've found how to create a screen of a dive using html2canvas and to open it in a new tab, it works perfectly : function printDiv2(div) { html2canvas((div), { onrendered: function(canvas) { var img = canvas.toDataURL(); window.open(img); } }); } But for thee Save as part, is a kind of the tough part... I've found interesting topics, as I'm new in JS (and object) coding, I

Generate an image of a div and Save as

我们两清 提交于 2020-01-22 09:29:54
问题 I'd like to create an input button "Save image" that : take a screen shot of a div ask to "Save as" on the user's computer I've found how to create a screen of a dive using html2canvas and to open it in a new tab, it works perfectly : function printDiv2(div) { html2canvas((div), { onrendered: function(canvas) { var img = canvas.toDataURL(); window.open(img); } }); } But for thee Save as part, is a kind of the tough part... I've found interesting topics, as I'm new in JS (and object) coding, I

python获取小程序手机号并绑定

[亡魂溺海] 提交于 2020-01-22 04:42:48
最近在做小程序开发,在其中也遇到了很多的坑,获取小程序的手机号并绑定就遇到了一个很傻的坑。 流程介绍 官方流程图 小程序使用方法 需要将 <button> 组件 open-type 的值设置为 getPhoneNumber,当用户点击并同意之后,可以通过 bindgetphonenumber 事件回调获取到微信服务器返回的加密数据, 然后在第三方服务端结合 session_key 以及 app_id 进行解密获取手机号。 <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"> </button> 返回参数说明 参数 类型 说明 encryptedData String 包括敏感数据在内的完整用户信息的加密数据,详细见 加密数据解密算法 iv String 加密算法的初始向量,详细见 加密数据解密算法 接受到这些参数以后小程序把code,encryptedData,iv发给后台,然后后台解密 后台解密 在解密以前需要session_key进行配合解密,所以首先通过code获取session_key # 获取openid,session_key # Appid为小程序id openid_url = "https://api.weixin.qq.com/sns/jscode2session?appid

How to base64 encode image in linux bash / shell

和自甴很熟 提交于 2020-01-22 04:12:32
问题 I'm trying to base64 encode an image in a shell script and put it into variable: test="$(printf DSC_0251.JPG | base64)" echo $test RFNDXzAyNTEuSlBH I've also tried something like this: test=\`echo -ne DSC_0251.JPG | base64\` but still with no success. I want to do something like this: curl -v -X POST -d '{"image":$IMAGE_BASE64,"location":$LOCATION,"time_created":$TIMECREATED}' -H 'Content-type: text/plain; charset=UTF8' http://192.168.1.1/upload I found this http://www.zzzxo.com/q/answers

How to base64 encode image in linux bash / shell

心不动则不痛 提交于 2020-01-22 04:12:26
问题 I'm trying to base64 encode an image in a shell script and put it into variable: test="$(printf DSC_0251.JPG | base64)" echo $test RFNDXzAyNTEuSlBH I've also tried something like this: test=\`echo -ne DSC_0251.JPG | base64\` but still with no success. I want to do something like this: curl -v -X POST -d '{"image":$IMAGE_BASE64,"location":$LOCATION,"time_created":$TIMECREATED}' -H 'Content-type: text/plain; charset=UTF8' http://192.168.1.1/upload I found this http://www.zzzxo.com/q/answers

How to save canvas image using classic ASP?

﹥>﹥吖頭↗ 提交于 2020-01-21 03:34:20
问题 I'm a bit stuck here. I know that I can use the canvas.toDataURL to produce a base64 encoded string to pass to a classic ASP page on my server. But the problem I can't seem to find an answer to is how to process this data so I can save it someplace on my server. So with this snippet of code on my HTML page, I pull the canvas data (I pulled this from another post here at StackOverflow): var dataURL = renderedCanvas.toDataURL("image/png"); dataURL = dataURL.replace('data:image/png;base64,', '')

对接腾讯IM碰到的一些问题

旧巷老猫 提交于 2020-01-20 14:03:17
最近项目中用到了腾讯IM,对接的过程中碰到了一些问题,记录一下这些坑。 类找不到异常:sun.misc.BASE64Encoder 使用官方文档中生成签名的方法中用到这个类,一开始在本地可以,部署到服务器却一直报类找不到,看了一眼这个类是jdk里的呀,怎么会找不到,难道是jdk中有猫腻? 马上查了一下本地和服务器jdk的版本,果然不一样,本地1.8,服务器11,11中就删了? 百度了一下,果然,从jdk9开始删除了rt.jar,而这个类正好在这个jar中,解决办法就是换一种base64的解密类,有很多,我换成了: java.util.Base64 加密:Base64.getEncoder().encodeToString 解密:Base64.getDecoder().decode 来源: CSDN 作者: 哈士奇有点萌 链接: https://blog.csdn.net/qq_33834106/article/details/104050725

How to export HTML text with embedded images (base64, data uri) using the htmlcomponent?

拈花ヽ惹草 提交于 2020-01-20 08:30:30
问题 We have HTML from database, and we would like to create a Word report with this HTML. This HTML comes from users, and may contain only formatted text (bold, italic...), or text + embedded image encoded in base64 way. Example: <b>My photo :</b> <img src="data:image/png;base64,iVBORw0K... " /> We know that with textField , markup="html" , it does not work with img html tags. With Jasper Studio 6.3.1, we tried with <hc:html/> , it works with image on the hard drive, but it won't work with

python的base64编码代码实现

*爱你&永不变心* 提交于 2020-01-20 01:22:33
python的base64编码代码实现(学习记录) base64_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'] def encode_ascii(string: str) -> str: temp = '' base = '' # 把原始字符串转换为二进制,用bin转换后去掉开头的0b,首位补0补齐8位 for i in string: temp += '{:08}'.format(int(str(bin(ord(i))).replace('0b', ''))) # 6位一组截取,最后一组不足6位的后面补0,获取base_list中对应的字符 for j in range(0,

加密与安全

泪湿孤枕 提交于 2020-01-19 17:49:08
一, URL 编码 为什么要使用 URL 编码? 我们都知道Http协议中参数的传输是 "key=value" 这种简直对形式的,如果要传多个参数就需要用 “&” 符号对键值对进行分割。如 "?name1=value1&name2=value2" ,这样在服务端在收到这种字符串的时候,会用 “&” 分割出每一个参数,然后再用 “=” 来分割出参数值。 现在有这样一个问题,如果我的参数值中就包含=或&这种特殊字符的时候该怎么办。 比如说 “name1=value1” ,其中value1的值是 “va&lu=e1” 字符串,那么实际在传输过程中就会变成这样 “name1=va&lu=e1” 。我们的本意是就只有一个键值对,但是服务端会解析成两个键值对,这样就产生了奇异。 如何解决上述问题带来的歧义呢?解决的办法就是对参数进行URL编码? URL编码只是简单的在特殊字符的各个字节前加上%,例如,我们对上述会产生奇异的字符进行URL编码后结果: “name1=va%26lu%3D” ,这样服务端会把紧跟在“%”后的字节当成普通的字节,就是不会把它当成各个参数或键值对的分隔符。 类似于这种 实际操作 public static void main(String[] args) { //url编码 String str="测试"; String urlStr=URLEncoder.encode