jq

Java实现文件的加密与解密

丶灬走出姿态 提交于 2021-01-03 16:23:32
最近在做一个项目,需要将资源文件(包括图片、动画等类型)进行简单的加密后再上传至云上的服务器,而在应用程序中对该资源使用前先将读取到的文件数据进行解密以得到真正的文件信息。此策略的原因与好处是将准备好的资源存储在云上,使用时通过网络进行读取即可,减少了应用程序本身的大小。这一点对于移动应用尤其重要,特别是在资源量较大且需要对其进行保护的时候。毕竟在目前所处的大环境下,要想复制一款软件不难,那真正宝贵的就是不容易找到的资源了。   先对文件与加密的相关知识做一个极为简单的科普(知道的可以跳过)。    文件与字串   A、文件的操作流程一般为:打开-->读取-->对内容进行变换-->写入-->关闭。   B、常规性文件操作会用到的类有五个:File,InputStream,OutputStream,FileInoutStream,FileOutputStream,均包含在java.io下面。注意,在使用前必须对类文件进行导入,方法为import java.io.File(实现时需要分号结尾)。   C、创建InputStream类和OutputStream类的对象时,new关键字后边的类分别是FileInputStream和FileOutputStream(而不是其自身),如InputStream fin = new FileInputStream(File objectFile)

“pip install jq” generates errors on Mac and Windows

微笑、不失礼 提交于 2021-01-02 05:08:53
问题 Duplicate of this issue, but the first answer there is wrong ( jq is supported on Windows) and the second refers to brew so I'm guessing is for Mac. Windows I am trying to install jq for python from the Windows command line, but get the following errors, possibly due to a missing temp\pip-build-rtnhmg\jq\onig-install-5.9.6 file: error: [Error 2] The system cannot find the file specified ... and ... Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\

In jq, how to get tonumber to output decimal instead of scientific notation

青春壹個敷衍的年華 提交于 2020-12-31 10:55:05
问题 In a JSON object, given the string "0.0000086900" as the value of a key-value pair, if I do |tonumber on this, 8.69e-06 gets returned. How can I ensure that only decimals are ever returned? In the case above, this would be 0.0000086900 SOLUTION (based on Peak's code snippet below) def to_decimal: def rpad(n): if (n > length) then . + ((n - length) * "0") else . end; def lpad(n): if (n > length) then ((n - length) * "0") + . else . end; tostring | . as $s | [match( "(?<sgn>[+-]?)(?<left>[0-9]*

In jq, how to get tonumber to output decimal instead of scientific notation

你说的曾经没有我的故事 提交于 2020-12-31 10:54:46
问题 In a JSON object, given the string "0.0000086900" as the value of a key-value pair, if I do |tonumber on this, 8.69e-06 gets returned. How can I ensure that only decimals are ever returned? In the case above, this would be 0.0000086900 SOLUTION (based on Peak's code snippet below) def to_decimal: def rpad(n): if (n > length) then . + ((n - length) * "0") else . end; def lpad(n): if (n > length) then ((n - length) * "0") + . else . end; tostring | . as $s | [match( "(?<sgn>[+-]?)(?<left>[0-9]*

In jq, how to get tonumber to output decimal instead of scientific notation

和自甴很熟 提交于 2020-12-31 10:54:27
问题 In a JSON object, given the string "0.0000086900" as the value of a key-value pair, if I do |tonumber on this, 8.69e-06 gets returned. How can I ensure that only decimals are ever returned? In the case above, this would be 0.0000086900 SOLUTION (based on Peak's code snippet below) def to_decimal: def rpad(n): if (n > length) then . + ((n - length) * "0") else . end; def lpad(n): if (n > length) then ((n - length) * "0") + . else . end; tostring | . as $s | [match( "(?<sgn>[+-]?)(?<left>[0-9]*

How do i add an index in jq

岁酱吖の 提交于 2020-12-29 13:12:22
问题 I want to use jq map my input ["a", "b"] to output [{name: "a", index: 0}, {name: "b", index: 1}] I got as far as 0 as $i | def incr: $i = $i + 1; [.[] | {name:., index:incr}]' which outputs: [ { "name": "a", "index": 1 }, { "name": "b", "index": 1 } ] But I'm missing something. Any ideas? 回答1: It's easier than you think. to_entries | map({name:.value, index:.key}) to_entries takes an object and returns an array of key/value pairs. In the case of arrays, it effectively makes index/value pairs

How do i add an index in jq

橙三吉。 提交于 2020-12-29 13:09:37
问题 I want to use jq map my input ["a", "b"] to output [{name: "a", index: 0}, {name: "b", index: 1}] I got as far as 0 as $i | def incr: $i = $i + 1; [.[] | {name:., index:incr}]' which outputs: [ { "name": "a", "index": 1 }, { "name": "b", "index": 1 } ] But I'm missing something. Any ideas? 回答1: It's easier than you think. to_entries | map({name:.value, index:.key}) to_entries takes an object and returns an array of key/value pairs. In the case of arrays, it effectively makes index/value pairs

How do i add an index in jq

柔情痞子 提交于 2020-12-29 13:08:48
问题 I want to use jq map my input ["a", "b"] to output [{name: "a", index: 0}, {name: "b", index: 1}] I got as far as 0 as $i | def incr: $i = $i + 1; [.[] | {name:., index:incr}]' which outputs: [ { "name": "a", "index": 1 }, { "name": "b", "index": 1 } ] But I'm missing something. Any ideas? 回答1: It's easier than you think. to_entries | map({name:.value, index:.key}) to_entries takes an object and returns an array of key/value pairs. In the case of arrays, it effectively makes index/value pairs

java命名规范

爱⌒轻易说出口 提交于 2020-12-28 14:18:19
一、命名规范 1、 项目名全部小写 2、 包名全部小写 3、 类名首字母大写,如果类名由多个单词组成,每个单词的首字母都要大写。 如:public class MyFirstClass{} 4、 变量名、方法名首字母小写,如果名称由多个单词组成,每个单词的首字母都要大写。 如:int index=0; public void toString(){} 5、 常量名全部大写 如:public static final String GAME_COLOR=”RED”; 6、所有命名规则必须遵循以下规则: 1)、名称只能由字母、数字、下划线、$符号组成 2)、不能以数字开头 3)、名称不能使用JAVA中的关键字。 4)、坚决不允许出现中文及拼音命名。 二、注释规范 1、 类注释 在每个类前面必须加上类注释,注释模板如下: /** Copyright (C), 2006-2010, ChengDu Lovo info. Co., Ltd. FileName: Test.java 类的详细说明 @author 类创建者姓名 @Date 创建日期 @version 1.00 */ 2、 属性注释 在每个属性前面必须加上属性注释,注释模板如下: /** 提示信息 */ private String strMsg = null; 3、 方法注释 在每个方法前面必须加上方法注释,注释模板如下: /*

Break jq query string into lines

放肆的年华 提交于 2020-12-26 05:24:47
问题 How can i break jq string into lines, this is for long lines, when i put "\" query breaks. vpcExists=$(aws ec2 describe-vpcs --profile $profile | jq -r --arg vpcId "$vpcId" '.[][] | \ select(.VpcId == $vpcId) \ | .["State"]' \ ) 回答1: jq is fine with literal line breaks, so just add linefeeds anywhere without trying to escape them: vpcExists=$(aws ec2 describe-vpcs --profile $profile | jq -r --arg vpcId "$vpcId" ' .[][] | select(.VpcId == $vpcId) | .["State"]' ) Here's a MCVE: jq -r --arg