sign

c++ 手写计算器

◇◆丶佛笑我妖孽 提交于 2019-12-01 20:54:21
数据结构课上老师布置了个作业,让自己写一个计算器,要求支持小数运算及括号,早上刷牙时构思了一下,发现可以用两个栈来实现。 其中,一个栈用来存运算符,一个栈用来存运算的数,利用栈将输入的中缀表达式转化为计算器好识别的后缀表达式,当存运算符的栈中pop出运算符时,就取存运算数的栈上的前两个进行运算,在将运算结果压入栈中。 具体实现代码如下 #include<iostream> #include<cstring> #include<stack> using namespace std; stack<double> num; stack<char> sign; void calc(char c){ double a,b; a=num.top(); num.pop(); b=num.top(); num.pop(); if(c=='+') num.push(a+b); else if(c=='-') num.push(b-a); else if(c=='*') num.push(a*b); if(c=='/') num.push(b/a); } double solve(string s){ char top; double ans=0; char c; double n=0; int len=s.length(); double m=1,d=0; for(int i=0;i<len;i++

PHP RSA签名

喜夏-厌秋 提交于 2019-12-01 11:45:26
签名算法: Setp.1 确定待签名参数 在请求参数列表中,除去sign参数外,其他需要使用到的参数皆是要签名的参数。 在通知返回参数列表中,除去sign参数外,凡是通知返回回来的参数皆是要签名的参数。 Setp.2 对参数进行排序 对于待签名的所有参数,需要根据参数名首字符字典顺序(ascii值大小)排序,若遇到相同首字符,则判断第二个字符,以此类推。 Setp.3 生成待签名字符串 将排序后的待签名参数以“&“符号拼接, 形如:“参数名1=参数值1&参数名2=参数值2&….&参数名N=参数值N”。 Setp.4 生成签名/验证签名 生成签名:把待签名字符串与商户的私钥一同放入RSA的签名函数中进行签名运算,从而得到签名结果字符串(sign值)。 验证签名:把待签名字符串、平台提供的公钥、通知返回参数中的参数sign值三者一同放入RSA的签名函数中进行签名运算,来判断签名是否验证通过。 1、公钥、私钥格式化(加上前后戳、每64位进行换行) /**********************************私钥格式化*************************************/ 1 function formatPriKey($priKey) { 2 $fKey = "-----BEGIN PRIVATE KEY-----\n"; 3 $len = strlen(

【网络安全】加解密算法最详解

扶醉桌前 提交于 2019-12-01 11:37:42
数据签名、加密是前后端开发经常需要使用到的技术,应用场景包括不限于用户登入、数据交易、信息通讯等,不同的应用场景也会需要使用到不同的签名加密算法,或者需要搭配不一样的 签名加密算法来达到业务目标。常用的加密算法有: 对称加密算法; 非对称加密算法; 哈希算法,加盐哈希算法(单向加密); 数字签名。 使用加密签名算法,可以达到下面的安全目标: 保密性:防止用户的数据被读取; 数据完整性:防止数据被篡改; 身份验证:确保数据发自特定的一方。 对称加密 对称加密算法加密和解密时使用同一把秘钥。操作比较简单,加密速度快,秘钥简单。经常在消息发送方需要加密大量数据时使用。缺点是风险都在这个秘钥上面,一旦被窃取,信息会暴露。所以安全级别不够高。常用对称加密算法有DES,3DES,AES等。在jdk中也都有封装。 DES DES的秘钥为8个字节,64个bit位。(不适应当今分布式开放网络对数据加密安全性的要求)在Java进行DES、3DES和AES三种对称加密算法时,常采用的是NoPadding(不填充)、Zeros填充(0填充)、PKCS5Padding填充。 一个DES的列子: import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import

How to sign a generic text with RSA key and encode with Base64 in Java?

拈花ヽ惹草 提交于 2019-12-01 10:43:50
I have the following code in bash: signed_request = $(printf "PLAIN TEXT REQUEST" | openssl rsautl -sign -inkey "keyfile.pem" | openssl enc -base64 | _chomp ) Basically, this code takes a plain text, signs it with a private key and encodes using Base64 How could I do a code with exactly the same functionality in Java? You can use JDK security API . Take a look at this working sample , hope it can get you started: public static void main(String[] args) throws Exception { KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(1024); KeyPair keyPair = kpg.genKeyPair(); byte[]

i春秋exec

与世无争的帅哥 提交于 2019-12-01 09:18:50
打开是一个 gif ,提示文字未登录 话不多说,查看源码 发现 vim 字样,可能是文件泄露 直接在 url 后加 /.index.php.swp 来下载泄露文件 下载好了之后放 vm 上使用 vim -r .index.php.swp 修复文件 打开后的文件为 <html> <head> <title>blind cmd exec</title> <meta language='utf-8' editor='vim'> </head> </body> <img src=pic.gif> <?php /* flag in flag233.php */ function check($number) { $one = ord('1'); $nine = ord('9'); for ($i = 0; $i < strlen($number); $i++) { $digit = ord($number{$i}); if ( ($digit >= $one) && ($digit <= $nine) ) { return false; } } return $number == '11259375'; } if(isset($_GET[sign])&& check($_GET[sign])){ setcookie('auth','tcp tunnel is forbidden!'); if

【网络安全】加解密算法最详解

两盒软妹~` 提交于 2019-12-01 08:12:29
数据签名、加密是前后端开发经常需要使用到的技术,应用场景包括不限于用户登入、数据交易、信息通讯等,不同的应用场景也会需要使用到不同的签名加密算法,或者需要搭配不一样的 签名加密算法来达到业务目标。常用的加密算法有: 对称加密算法; 非对称加密算法; 哈希算法,加盐哈希算法(单向加密); 数字签名。 使用加密签名算法,可以达到下面的安全目标: 保密性:防止用户的数据被读取; 数据完整性:防止数据被篡改; 身份验证:确保数据发自特定的一方。 对称加密 # 对称加密算法加密和解密时使用同一把秘钥。操作比较简单,加密速度快,秘钥简单。经常在消息发送方需要加密大量数据时使用。缺点是风险都在这个秘钥上面,一旦被窃取,信息会暴露。所以安全级别不够高。常用对称加密算法有DES,3DES,AES等。在jdk中也都有封装。 DES # DES的秘钥为8个字节,64个bit位。(不适应当今分布式开放网络对数据加密安全性的要求)在Java进行DES、3DES和AES三种对称加密算法时,常采用的是NoPadding(不填充)、Zeros填充(0填充)、PKCS5Padding填充。 一个DES的列子: Copy import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory;

[LeetCode] 8. String to Integer (atoi)

妖精的绣舞 提交于 2019-12-01 06:19:12
这题考察的是字符串转数字。需要注意的几个点是 1. 去掉字符串里面,前后所有的空格。例子," 111 23 4 4 "需要处理成"1112344",跳过所有的空格。 2. 先判断第一个char是不是一个正负号,若是负号记得最后乘以-1。 3. 判断每个char是不是介于0-9之间,若不是,立马退出循环。若是,就正常计算。 1 /** 2 * @param {string} str 3 * @return {number} 4 */ 5 var myAtoi = function(str) { 6 let i = 0; 7 let sign = 1; 8 let res = 0; 9 while (str.charAt(i) == ' ') { 10 i++; 11 } 12 if (str.charAt(i) === '+') { 13 i++; 14 } else if (str.charAt(i) === '-') { 15 sign = -1; 16 i++; 17 } 18 19 while (str.charAt(i) >= '0' && str.charAt(i) <= '9') { 20 res = res * 10 + (str.charAt(i) - 0); 21 if (res * sign >= 2147483647) { 22 return

PTA(Basic Level)1006.Sign In and Sign Out

China☆狼群 提交于 2019-12-01 06:18:07
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and locked the door on that day. Input Specification: Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M , which is the total number of records, followed by M lines, each in the format: ID_number Sign_in_time Sign_out_time where times are given in the format HH:MM:SS , and ID

How do you programmatically sign jar files in Java?

元气小坏坏 提交于 2019-12-01 04:14:49
Has anyone done this before? The only reference I have found on google has been: http://onjava.com/onjava/2001/04/12/signing_jar.html which still uses sun.* classes that will cause issues... Found this as well, but does not work with java16: https://svn.cs.cf.ac.uk/projects/whip/trunk/whip-core/src/main/java/org/whipplugin/data/bundle/JarSigner15.java To address a sudden change of security restrictions in WebStart applications in Java 7u45 we have created a simple signed jar file generator . It uses Guava 15 and Bouncy Castle bcpkix module. It should run on Java 6 & 7. It is suitable for small

How can I sign my Windows Store app from Window Store certificate?

本秂侑毒 提交于 2019-12-01 02:52:54
问题 I have just bought my developer account from the Windows Store, and I would like to sign my app before uploading. When I go inside the packaging and then I click on the choose certificate button, I see following options: Pick from certificate store Select from file Create test certificate. I tested everything with the third option but the first option, pick from certificate store, gives me error like below: No Certificate Available No certificates meet the application criteria. This is a