Java中JSON字符串指定某个key进行加密

Json字符串:{"code":"0000","success":true,"results":{"code":"0000","userId":364,"openid":"null","shopId":null,"brandId":66,"roleId":1,"entityName":null,"menuList":[{"id":258,"name":"xxx","pid":255,"type":2},{"id":259,"name":"xxx","pid":255,"type":2}],"loginName":"xxx"}}
需求:shopId,id 这两个属性值进行加密
有什么好的办法,正则替换什么的。

因为字符串内容是未知的,不能装换成JSON对象操作

已经解决了
图片说明
图片说明

10个回答

哦看到了,其实也可以用instanceof判断,不过还是没indexOf判断的精确。

是用阿里巴巴的fastjson 将字符串转成 JSONOBject 对象,从对象中到 shopID, id值,并进行加密 后重新赋值,在转成json字符串

csdn_shj
csdn_shj 回复伍熙吖: indexOf("shopId":) 然后。。。
2 年多之前 回复
qq_30212947
伍熙吖 不行的 我这个是不知道json字符串格式是什么样的 里面可能是jsonArray 也可以是jsonobj 也可能是jsonobj里面属性是jsonarray
2 年多之前 回复

可以先把json串转成json对象,然后加密参数,再将json对象转换成json字符串
例如:
String jsonStr = "{\"shopId\":\"200\"}";
JSONObject jSONObject = JSONObject.fromObject(jsonStr);
String shopId = jSONObject.getString("shopId");
jSONObject.put("shopId", "加密后的字符串");

再转换成JSON对象,再将JSON对象中的id和shopId两个属性进行加密,最后再转换成json字符串。

JSONObject jsonObj= JSONObject.fromObject(jsonStr);

String value= jsonObj.getString(key);

JSONObject jsonObj= JSONObject.fromObject(jsonStr);
String value= jsonObj.getString(key);

用google的Gson转嘛。

看看能不能转成Map,然后遍历

用android studio 的插件,gsonformat,把json串放进去,自动生成bean,省事。。。

已经解决了 在内容里面有代码

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
在PHP中加密字符串并在Node.js中解密

<div class="post-text" itemprop="text"> <p>I am sending data through insecure connection between Apache and Node.js servers. I need to encrypt data in PHP and decrypt in Node.js. I've spent 2 days trying to get it to work, however I only managed to get message signing to work, no encryption. I tried passing AES128-CBC, AES256-CBC, DES, AES128, AES256 as algorithms, however nothing worked well..</p> <p>I tried this in PHP:</p> <pre><code>$data = json_encode(Array('mk' =&gt; $_SESSION['key'], 'algorithm' =&gt; 'SHA1', 'username' =&gt; $_SESSION['userid'], 'expires' =&gt; $expires)); $payload = openssl_encrypt($data, 'des', '716c26ef'); return base64_encode($payload); </code></pre> <p>And in Node.js:</p> <pre><code>var enc_json = new Buffer(response[1], 'base64'); var decipher = crypto.createDecipher('des', '716c26ef'); var json = decipher.update(enc_json).toString('ascii'); json += decipher.final('ascii'); </code></pre> <p>And besides wrong decrypted data I get error such as these:</p> <pre><code>TypeError: error:0606508A:digital envelope routines:EVP_DecryptFinal_ex:data not multiple of block length TypeError: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length </code></pre> <p>I need a simple encryption as data is not too sensitive (no password or user data), however data should only be read by the recipient. Key length can be anything, but procedure to encrypt/decrypt has to be as simple as possible, please no IVs.</p> </div>

关于PHP和JAVA之间的AES加密互通问题

公司今日接到一个需求,要与银行方面进行对接,接收银行方面 推送过来的加密信息,解密后入库进行统计,由于银行方是JAVA环境,我司是PHP环境,所以需要写一个PHP的解密方法,查阅各种文档后还是无法满足需求,无法进行解密,特来求助. 银行方只有一个加密流程文档: 加密方式:AES/ECB/PKCS5Padding 1、将data中的字段转成json格式如下: ``` {"userId":"12345678911111233","state":"2","cardNo":"625966","time":"20171212","extInfo":""} ``` 2、URLEncode对josn字符串进行编码UTF-8防止中文乱码 ``` URLEncoder.encode(data, "UTF-8") %7B%22userId%22%3A%2212345678911111233%22%2C%22state%22%3A%222%22%2C%22cardNo%22%3A%22625966%22%2C%22time%22%3A%2220171212%22%2C%22extInfo%22%3A%22%22%7D ``` 3、使用aesKey对URLEncode后的字符串进行AES加密, 得到data: ``` aesKey=Spdbccc-testtest XBD5nXa7oAnsWo/l843zUfmuhpmWGKEieJoJXxZEHPun1zfQhEPBFKv5kXZMM8i2Vr9RJwZeW/zn6OScGSlRTNVaytu2M5CDABw6B1grqxCqjTu/fKTp3hpMJd0riMB7H7ZK5xGUBu2nGgacjPmVcVl8Xm34fdArx17DkHbHqOWgiwmesk0C/lgKK7hkyuiuVtEQPmc02Ipjx3JGyJ+59g== ``` 我这边先是按照查询的文档中所说直接使用PHP自带的mcrypt扩展进行解密,发现php7.2已经弃用该扩展,换成openssl方式使用AES-128-ECB进行解密返回值是false;后来我转变思路,先用openssl以AES-128-ECB模式对第二步的串进行加密,获取到的结果和步骤三中的完全不一样,我改用先获取openssl的加密模式列表然后循环加密,输出各个加密方式的结果,发现没有一个能对上,到此以我的水平已经不知道该如何进行下一步了,特来求助!

API请求 所有参数按照字段名的ascii码从小到大排序后

URL:http://api.pcaexpress.com.au/tracking 请求类型:POST 请求参数: 参数 类型 api_id 字符串 必填 test 字符串 data 字符串 必填 sign 字符串 必填 除sign字段外,所有参数按照字段名的ascii码从小到大排序后使用keyvalue的格式(即key1value1key2=value2…)拼接而成,空值不传递,在拼接完的字符串前后俩段都加上API KEY密匙后进行MD5加密,最后将所有小写字母转为大写字母

将IOS中的加密J​​SON数据发送到PHP进行解密

<div class="post-text" itemprop="text"> <p>I have a function which requires me to send a encrypted JSON instance to a PHP server for validation. I have a problem trying to get the whole process up and running and messing my head to find out where the problem is.</p> <pre><code>-(void) sendData:(NSString*)theweb{ //preparing sample json NSMutableDictionary * dict = [[NSMutableDictionary alloc]init]; [dict setObject:@"test" forKey:@"example"]; [dict setObject:@"1" forKey:@"p"]; [dict setObject:@"yourPostMessage" forKey:@"test"]; [dict setObject:@"isNotReal" forKey:@"this"]; //json creation NSData* data2 = [JSONBuilder toJSON:dict]; NSString * jsonstring = [[NSString alloc]initWithData:data2 encoding:NSUTF8StringEncoding]; //creating a dummy sha256 hash for aes256 key. NSString * string3 = [self sha256HashFor:@"hello"]; //trimming hash to 32 character key. string3 = [string3 substringToIndex:32]; //encrypting data to aes256 data2 = [data2 AES256EncryptWithKey:string3]; NSString * b64= [data2 base64EncodedString]; NSString *post = [NSString stringWithFormat:@"theRealData=%@",b64]; NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO]; requestObj = nil; //NSMutableRequest requestObj = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:theweb]]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; [requestObj setValue:@"application/x-www-form-urlencoded;charset=charset=us-ascii" forHTTPHeaderField:@"Content-Type"]; [requestObj setValue:postLength forHTTPHeaderField:@"Content-Length"]; [requestObj setHTTPMethod:@"POST"]; [requestObj setHTTPBody:postData]; //calling a new NSURLConnection conn = nil; conn = [NSURLConnection connectionWithRequest:requestObj delegate:self]; [conn start]; } </code></pre> <p>The methods used in this function are as follows:</p> <pre><code>+(NSData*)toJSON :(NSMutableDictionary*)dictionary { NSError* error = nil; id result = [NSJSONSerialization dataWithJSONObject:dictionary options:kNilOptions error:&amp;error]; if (error != nil) return nil; return result; } -(NSString*)sha256HashFor:(NSString*)input { const char* str = [input UTF8String]; unsigned char result[CC_SHA256_DIGEST_LENGTH]; CC_SHA256(str, strlen(str), result); NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2]; for(int i = 0; i&lt;CC_SHA256_DIGEST_LENGTH; i++) { [ret appendFormat:@"%02x",result[i]]; } return ret; } - (NSData *)AES256EncryptWithKey:(NSString *)key { // 'key' should be 32 bytes for AES256, will be null-padded otherwise char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused) bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding) // fetch key data [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding]; NSUInteger dataLength = [self length]; //See the doc: For block ciphers, the output size will always be less than or //equal to the input size plus the size of one block. //That's why we need to add the size of one block here size_t bufferSize = dataLength + kCCBlockSizeAES128; void *buffer = malloc(bufferSize); size_t numBytesEncrypted = 0; CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, keyPtr, kCCKeySizeAES256, NULL /* initialization vector (optional) */, [self bytes], dataLength, /* input */ buffer, bufferSize, /* output */ &amp;numBytesEncrypted); if (cryptStatus == kCCSuccess) { //the returned NSData takes ownership of the buffer and will free it on deallocation return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted]; } free(buffer); //free the buffer; return nil; } </code></pre> <p>Here's the code on php:</p> <pre><code>function decrypt_data($data, $key) { //$padded_key = $key . str_repeat(chr(0x00), 16); // Argh! //var_dump($padded_key); var_dump(base64_decode($data,true)); $result = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($data), 'ecb'); var_dump($result); // Yetch - $result ends up being padded with 0x0b's (vertical tab). $result2 = rtrim($result, chr(0x0b)); return $result2; } </code></pre> <p>Here are my findings:</p> <pre><code>Output of Base64 string(Gotten on both sides): UalnWmRiMQv8z4mEm+6B3HFSbiDwWcK1LYPhk6jDq+DiwYzvxqoZuDnlJUAjWbX6sQepiL8fb8/JQ0NXhQocglIcJN759AbpVSsbiXmwL78= Output of vardump on base64_decode on PHP side: BOOL(false) Output of vardump on $result: none </code></pre> <p>Somehow I have this feeling that the problem lies with the encoding. Could someone guide me on this? I am at a loss.</p> </div>

oc 用DES加密+base64编码后 ,得到的字符串结尾有一小段乱码

oc 用DES加密+base64编码后 ,得到的字符串结尾有一小段乱码,而且很难复现,哪位大神懂,求助 base64是用GTMBase64,,DES加密方法如下: + (NSString *)encryptDESUseCBCModel:(NSString *)clearText key:(NSString *)key vi:(NSString *)vi { NSData *data = [clearText dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; unsigned char buffer[[data length]]; memset(buffer, 0, sizeof(char)); size_t numBytesEncrypted = 0; const void *vinitVec = (const void *) [vi UTF8String]; CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmDES, kCCOptionPKCS7Padding /*| kCCOptionECBMode*/, [key UTF8String], kCCKeySizeDES, vinitVec, [data bytes], [data length], buffer, 100000000, &numBytesEncrypted); NSString* plainText = nil; if (cryptStatus == kCCSuccess) { NSData *dataTemp = [NSData dataWithBytes:buffer length:(NSUInteger)numBytesEncrypted]; plainText = [GTMBase64 stringByEncodingData:dataTemp]; }else{ TestLog(@"DES加密失败"); } return plainText; } NSString *jsonString = [parameters JSONString]; NSString *encodeJsonString = [EncryptUtil encryptDESUseCBCModel:jsonString key:kEncryptKey vi:kEncryptVi];

C# winform程序实现JAVA josn 请求接

第一次写winfrom 不知道怎么写,以下是给的接口说明 HTTP请求方式:GET http://ip:port/lanshuijsdService/3.0/hts/queryCyr?param_key=?&secret_key=? 1) 注意: 以JSON格式传入输入参数 1) 请求参数 参数名称 类型 必需 描述 param_key 字符串 是 输入参数值 secret_key 字符串 是 Md5摘要信息 Param_key中包含的输入json中的字段描述如下: 参数名称 类型 必需 描述 meraccount string 是 商户账户(321000000) method string 是 API的资源操作方法名(queryCyr) timestamp number 是 用户发起请求时的unix时间戳。 v number 是 API版本号,默认使用最高版本(1.0)。 ⦁ 请求示例: 将param_key内的json中元素按照参数名排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串后进行MD5,以形成secret_key值 param_key值=RSA(URLEncoder ({”name2”:”value2”, “name1”:”value1”,”name3”:”value3”},”UTF-8”)) secret_key值= URLEncoder (md5(name1=value1& name2=value2&name3=value3) ,”UTF-8”) ⦁ 签名算法 服务API使用的签名算法如下: ⦁ 获取请求的HTTP method; ⦁ 获取请求的URL,包括host和scheme,但不包括query_string的部分 ⦁ 将所有参数(包括GET或POST的参数,但不包含签名字段)格式化为“key=value”格式,如“k1=v1”、“k2=v2”、“k3=v3”; ⦁ 将格式化好的参数键值对以字典序升序排列后,拼接在一起,如“k1=v1&k2=v2&k3=v3”,并将HTTP method和URL按顺序拼接在这个字符串前面; ⦁ 在拼接好的字符串末尾追加上应用的secret_key,并进行urlencode形成base_string; ⦁ 上述字符串的MD5值即为签名的值: sign= urlencode(MD5(k1=v1&k2=v2&k3=v3)); ⦁ 安全加密 为了确保敏感数据的可靠传输。必须对传输数据使用RSA的公钥进行非对称加密,私钥由服务提供方妥善保管,公钥由客户端经过身份验证之后获得。安全加密算法如下: RSA(URLEncoder ({”name2”:”value2”, “name1”:”value1”,”name3”:”value3”},”UTF-8”)) 分配的RSA公钥如下: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsoGCMo/XE+fNlLQBLK4VBYe8pVZe71Eb5fZOxd213vvshmWA/9c+vSM/uUAcD/W/It+xnJE1TECCTbV6uCqgfmrztwe2OQS2kGhLPGIYfo9ha2NufghUNAHAB9M0m1lp7y2m8T27iPhy 下面我写的代码: string strURL = "http://192.168.200.207:8088/lsjsdService/3.0/hts/queryJsd?param_key="; string md5 = "MIGfMA0GCSqGSIb3DQEBAQUAA4GyRRxv35xuamvvnzQDOerH3yrrCLnJ6bQIDAQAB"; string pk="{\"val\":\"200005719465\",\"scode\":\"321000006\",\"date\":\"20180625\",\"flag\":\"0\",\"meraccount\":\"321000000\",\"method\":\"queryJsd\",\"v\":\"3.0\",\"timestamp\":\"20180707\",}"; string param_key = ToUrlEncode(pk); string sk = "var=200005719465&scode=321000006&date=20180625&flag=0&meraccount=321000000&method=queryJsd&v=3.0&timestamp=20180707"; string secret_key = sign(sk, md5, "UTF-8"); strURL = "http://192.168.200.207:8088/lsjsdService/3.0/hts/queryJsd?param_key=" + param_key + "&secret_key=" + secret_key; string h = HttpApi(strURL, "{}", "get"); public static string ToUrlEncode(string strCode) { StringBuilder sb = new StringBuilder(); byte[] byStr = System.Text.Encoding.UTF8.GetBytes(strCode); //默认是System.Text.Encoding.Default.GetBytes(str) System.Text.RegularExpressions.Regex regKey = new System.Text.RegularExpressions.Regex("^[A-Za-z0-9]+$"); for (int i = 0; i < byStr.Length; i++) { string strBy = Convert.ToChar(byStr[i]).ToString(); if (regKey.IsMatch(strBy)) { //是字母或者数字则不进行转换 sb.Append(strBy); } else { sb.Append(@"%" + Convert.ToString(byStr[i], 16)); } } return (sb.ToString()); } public static string sign(string content, string privateKey, string input_charset) { Encoding code = Encoding.GetEncoding(input_charset); byte[] Data = code.GetBytes(content); RSACryptoServiceProvider rsa = DecodePemPrivateKey(privateKey); SHA1 sh = new SHA1CryptoServiceProvider(); byte[] signData = rsa.SignData(Data, sh); return Convert.ToBase64String(signData); } /// <summary> /// 调用api返回json /// </summary> /// <param name="url">api地址</param> /// <param name="jsonstr">接收参数</param> /// <param name="type">类型</param> /// <returns></returns> public static string HttpApi(string url, string jsonstr, string type) { Encoding encoding = Encoding.UTF8; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);//webrequest请求api地址 request.Accept = "text/html,application/xhtml+xml,*/*"; request.ContentType = "application/json"; request.Method = type.ToUpper().ToString();//get或者post byte[] buffer = encoding.GetBytes(jsonstr); request.ContentLength = buffer.Length; request.GetRequestStream().Write(buffer, 0, buffer.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) { return reader.ReadToEnd(); } } 文档里说的:param_key,secret_key 这两个值我都不知道我转换对没?以上我拼接的字符串正确吗?sign方法老是报错 ![图片说明](https://img-ask.csdn.net/upload/201807/08/1531032895_957209.png) 请大神帮忙指教下。

如何在python中编码字符串并在php服务器上解码它

<div class="post-text" itemprop="text"> <p>I have a python app that communicates with a php server. I am trying to pass an encrypted string from the python app to the php server to be decoded and stored:</p> <p><strong>Python Code</strong></p> <pre><code>url = "http://www.steventaylordevelopment.com/php/rk2.php" entry = {"username": encode("sdjfkhkj2h34", "username"), "mode": "hardcore", "score": 121114, "attempts": 15, "time": 12121, "rank": "prince"} d = {"action": "addEntry", "entry": json.dumps(entry)} r = requests.post(url=url, data=d) </code></pre> <p>encode function:</p> <pre><code>def encode(key, string): encoded_chars = [] for i in range(len(string)): key_c = key[i % len(key)] encoded_c = chr(ord(string[i]) + ord(key_c) % 256) encoded_chars.append(encoded_c) encoded_string = ''.join(encoded_chars) return encoded_string </code></pre> <p><strong>PHP code</strong></p> <pre><code>$entry = json_decode($_POST["entry"], true); $decoded_username = decode("sdjfkhkj2h34", $entry["username"]); $new_entry = $rk2_db-&gt;prepare("INSERT INTO leaderboard (username, mode, score, attempts, time, rank, date) VALUES (?, ?, ?, ?, ?, ?, NOW())"); $new_entry-&gt;bind_param("ssiiis", $decoded_username, $entry["mode"], $entry["score"], $entry["attempts"], $entry["time"], $entry["rank"]); $new_entry-&gt;execute(); $new_entry-&gt;close(); </code></pre> <p>decode function</p> <pre><code>function decode($key, $string){ $encoded_chars = array(); for($i = 0; $i &lt; strlen($string); $i++){ $key_c = $key[$i % strlen($key)]; $encoded_c = chr((ord($string[$i]) - ord($key_c) + 256) % 256); array_push($encoded_chars, $encoded_c); } $decoded_string = implode("", $encoded_chars); return $decoded_string; </code></pre> <p>I have tested the encode/decode function pairing separately and they function properly, but once i try to pass the encoded string with the http request (using python requests) things go haywire and it doesn't decode the string properly. How can i pass this encrypted string to my php server and then decode it?</p> <p><strong>Note</strong></p> <p>I am aware this isn't at all secure. That is not of importance as the information isn't sensitive. As a programming exercise I am trying to add a simple layer of obfuscation to the information being passed. I am just trying to figure out why the encrypted string is not being decrypted properly on the server side.</p> </div>

为什么wordpress没有在参数中使用加密字符串

<div class="post-text" itemprop="text"> <p>I have written a curl function and in header i have passed few parameters. one parameter must be encrypted. so i have used AES algorithm to encrpt that string parameter. after encryption it contains some special character, number. when i send a request wordpress doesn't take the string parameter as it is to send the request.</p> <p>Same piece of code working fine outside the wordpress but in wordpress due to special char its giving me the error. </p> <p>is there any utf setting i need to do. so that wordpress will take the parameter as it is.</p> <pre><code>&lt;?phperror_reporting(E_ALL ^ E_WARNING);class AES{ const M_CBC = 'cbc'; const M_CFB = 'cfb'; const M_ECB = 'ecb'; const M_NOFB = 'nofb'; const M_OFB = 'ofb'; const M_STREAM = 'stream'; protected $_key; protected $cipher; protected $data; protected $mode; protected $IV; /** * * @param type $data * @param type $key * @param type $blockSize * @param type $mode */ function __construct($data = null, $key = null, $blockSize = null, $mode = null) { $this-&gt;setData($data); $this-&gt;setBlockSize($blockSize); $this-&gt;setKey($key); $this-&gt;setMode($mode); $this-&gt;setIV(""); } /** * * @param type $data */ public function setData($data) { $this-&gt;data = $data; } /** * * @param type $key */ public function setKey($key) { $this-&gt;_key = $key; } /** * * @param type $blockSize */ public function setBlockSize($blockSize) { switch ($blockSize) { case 128: $this-&gt;cipher = MCRYPT_RIJNDAEL_128; break; case 192: $this-&gt;cipher = MCRYPT_RIJNDAEL_192; break; case 256: $this-&gt;cipher = MCRYPT_RIJNDAEL_256; break; } } /** * * @param type $mode */ public function setMode($mode) { switch ($mode) { case AES::M_CBC: $this-&gt;mode = MCRYPT_MODE_CBC; break; case AES::M_CFB: $this-&gt;mode = MCRYPT_MODE_CFB; break; case AES::M_ECB: $this-&gt;mode = MCRYPT_MODE_ECB; break; case AES::M_NOFB: $this-&gt;mode = MCRYPT_MODE_NOFB; break; case AES::M_OFB: $this-&gt;mode = MCRYPT_MODE_OFB; break; case AES::M_STREAM: $this-&gt;mode = MCRYPT_MODE_STREAM; break; default: $this-&gt;mode = MCRYPT_MODE_ECB; break; } } /** * * @return boolean */ public function validateParams() { if ($this-&gt;data != null &amp;&amp; $this-&gt;_key != null &amp;&amp; $this-&gt;cipher != null) { return true; } else { return FALSE; } } public function setIV($IV) { $this-&gt;IV = $IV; } protected function getIV() { if ($this-&gt;IV == "") { $this-&gt;IV = mcrypt_create_iv(mcrypt_get_iv_size($this-&gt;cipher, $this-&gt;mode), MCRYPT_RAND); $this-&gt;IV = mb_convert_encoding($this-&gt;IV,'UTF-8'); } return $this-&gt;IV; } /** * @return type * @throws Exception */ public function encrypt() { if ($this-&gt;validateParams()) { $block = mcrypt_get_block_size($this-&gt;cipher, $this-&gt;mode); $padding = $block - (strlen($this-&gt;data) % $block); $this-&gt;data .= str_repeat(chr($padding), $padding); return trim(base64_encode( mcrypt_encrypt( $this-&gt;cipher, $this-&gt;_key, $this-&gt;data, $this-&gt;mode, $this-&gt;getIV()))); } else { throw new Exception('Invalid params!'); } } /** * * @return type * @throws Exception */ public function decrypt() { if ($this-&gt;validateParams()) { return trim(mcrypt_decrypt( $this-&gt;cipher, $this-&gt;_key, base64_decode($this-&gt;data), $this-&gt;mode, $this-&gt;getIV())); } else { throw new Exception('Invalid params!'); } } } ?&gt;&lt;?php date_default_timezone_set("UTC"); $t = microtime(true); $sig_data= date('Y-m-d H:i:s.', substr($t, 0, -3)) . substr($t,-3); /// Add your API Key $api_key='71ae815b-6075-XXXXX-a12d7878bf47'; /// Add your API Secret $private_key='079499d582934XXXXc4dbd12645e4581'; $mode='cbc'; $blockSize = 128; /// Generate the Signature $aes = new AES($sig_data, $private_key, $blockSize, $mode); $enc = $aes-&gt;encrypt(); echo $enc; $en = preg_replace('/[^a-zA-z]/', 'p', $enc); echo $en; /// Call the GetProducts Method $url="https://api.omgpm.com/network/OMGNetworkApi.svc/v1.1/ProductFeeds/GetProductsByCategory?".http_build_query(array('AgencyID' =&gt; 95, 'AID' =&gt; 861823, 'MID' =&gt;$mid, "CategoryKeyword" =&gt; $opt_category ,"NumberOfRecords"=&gt;10, 'MinPrice' =&gt; 5000000, 'MaxPrice' =&gt; 99999999999, 'Currency' =&gt; 'INR', 'DiscountedOnly' =&gt; 'false', 'ProductSKU' =&gt; '', 'Key' =&gt; $api_key, 'Sig' =&gt; $en, 'SigData' =&gt; $sig_data)); $headers = array("Content-Type: application/json","Accept: application/json","Access-Control-Request-Method: GET" ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);print_r($result); ?&gt; </code></pre> </div>

在用GO语言加密的同时,如何在c#中解密RSA加密的字符串。 解码OAEP填充时发生错误

<div class="post-text" itemprop="text"> <p>I have an application running on c# and another server application in go. I need to implement secure communication using rsa. <br>What i'am doing is I've initialized the RSA provider in my C# application and generated public key to extract Modulus and Exponent. Then concatenated the modulus (Hexadecimal) and exponent (int) and converted this string to Base64 string, send it to a GO endpoint. </p> <p>Here is C# code snippet</p> <pre><code>public string ConvertToPublicKey() { CspParameters rsaParameters = GetCspParameters(); RSACryptoServiceProvider provider = newRSACryptoServiceProvider(rsaParameters); string paramsXml = RsaProvider.ToXmlString(false); XDocument xDocument = XDocument.Parse(paramsXml); string modulus = xDocument.Descendants().FirstOrDefault(x =&gt; x.Name == "Modulus")?.Value ?? string.Empty; string exponent = xDocument.Descendants().FirstOrDefault(x =&gt; x.Name == "Exponent")?.Value ?? string.Empty; byte[] base64BytesOfModulus = Convert.FromBase64String(modulus); string hexaDecimalofModulus = BitConverter.ToString(base64BytesOfModulus).Replace("-", string.Empty); byte[] base64BytesOfExponent = Convert.FromBase64String(exponent); string hexadecimalOfExponent = BitConverter.ToString(base64BytesOfExponent).Replace("-", string.Empty); int intOfExponent = Convert.ToInt32(hexadecimalOfExponent, 16); byte[] publicKey = Encoding.UTF8.GetBytes($"{hexaDecimalofModulus};{intOfExponent}"); return Convert.ToBase64String(publicKey); } private static CspParameters GetCspParameters() { const string containerName = "KeyContainer"; return new CspParameters { KeyContainerName = containerName, Flags = CspProviderFlags.UseMachineKeyStore }; } </code></pre> <p>At Go endpoint I received public key and modulus correctly. Then I encrypted the message using public key and sent it back to c# application in response after converting encrypted message byte[] to base64.</p> <p>Here is GO code snippet</p> <pre><code>func GetLicenseInfo(responseWriter http.ResponseWriter,request*http.Request) { encryptionKey := request.Header.Get("Authorization") var decodedStringBytes, errors = b64.StdEncoding.DecodeString(encryptionKey) if errors == nil { var decodedString = string(decodedStringBytes) result := strings.Split(decodedString, ";") modulus := new(big.Int) modulus.SetString(result[0], 16) exponent, exponentErrors := strconv.Atoi(result[1]) if exponentErrors == nil { var someInfo = utils.GetInfo() var InfoInJson = ToJson(someInfo) publicKey := &amp;rsa.PublicKey{N: modulus, E: exponent} var encryptedMessage, err = rsa.EncryptOAEP(sha256.New(),rand.Reader, publicKey,[]byte(InfoInJson), []byte("")) var response = b64.StdEncoding.EncodeToString(encryptedMessage) if err == nil { json.NewEncoder(responseWriter).Encode(response) } } } } func ToJson(model InfoModel) string { InfoInJson, errors := json.Marshal(model) if errors != nil { panic("An error occurred while serializing the response") } return string(InfoInJson) } </code></pre> <p>When i received the response back in Base64 string i converted it to <code>Byte[]</code> and tried decrypting that with same instance of <code>RSACryptoServiceProvider</code> then it throws the following exception</p> <blockquote> <p>Error occurred while decoding OAEP padding.</p> </blockquote> <p>any help?</p> <p><strong>UPDATE</strong> for example here is the base64 string that i received in GO </p> <blockquote> <p>QUQ2NDlFRTlCQTA3Q0IxNEI1MTNDMzczQzBBMjNBOEQyMDI5MkVGQTBFMjgyNUIyMEEyMzM1MEE3OTUyNjgyQ0Y3MEFBQjJBMTZGMzQyNTM4MkU2RDZBRjU5M0IxRTI2MTE0OEIyQkFFRTY3MUVDMTQ1NDk1NjBDRkNEQUNCQzI3RUUxNDRFODZDQUI4RDBDOUY2OENBNTUwNUMxQjZGQkVBQjQ0MTlBMjg3RDhBRjgxRDUyREY3MEM0RDZDQTA5MkREMzk5Q0NEODU5Q0FGQzAzQ0JEQ0JBQzgwOTg3NDY0NThBMkY4NEREOTc1QjU5QTJBMUNBNzQxQTBDNkQ2RDs2NTUzNw==</p> </blockquote> <p>and here is what my GO app sent back</p> <blockquote> <p>QuWpWdEPSJR+l9UJTkh+heJJ/NpPwhz/hVVu1VdKYdz37YGWWdKTj7Fc5lZ3A8p1WjtC4F+yieZCz0tEatCqTpRmm9g6Oioyjbtr9qGTxO/PE+GA33YyBe6nmMRe674SPePx/fg6l3nnfSZ4/+iLCV4bNgyNqFHCaXc7H4Snms8=</p> </blockquote> <p><strong>UPDATE 2</strong> I've updated the code snippet and included the data types and here is the part that dscrypts the content received from GO end point</p> <pre><code>public byte[] Decrypt(byte[] encryptedData, RSAParameters rsaParameters) { RsaProvider.ImportParameters(rsaParameters); return RsaProvider.Decrypt(encryptedData, true); } </code></pre> <p>i receive a base64 string then i convert to byte[] using this </p> <pre><code>byte[] b = Convert.FromBase64String(responseString); byte[] decryptedBytes=crypto.Decrypt(b, crypto.RsaProvider.ExportParameters(false)); </code></pre> <p>crypto is the instance of the class that contains decryption logic,instacne of <code>RSACryptoServiceProvider</code> and that method(ConvertToPublicKey) given above returning the public key</p> </div>

C#实现RSA签名,签名算法采用SHA-256,JAVA部分已有,因需要转为C#代码,望大神出手相助

package test; import java.math.BigInteger; import java.security.KeyFactory; import java.security.MessageDigest; import java.security.PrivateKey; import java.security.Signature; import java.security.spec.RSAPrivateKeySpec; import java.util.Calendar; import java.util.Date; public class test { public static void main(String[] args) throws Exception { String msg = "0|20140411|1\n银联基金交易账号|用户在基金公司的账号|申请日期|银联订单号|确认日期|基金公司确认编号|返回码|失败原因\n1040000000371674|20000015|20140410|20120528990000120140410000000120|20140411|2250000000016|0000|\n"; byte[] data = msg.getBytes("UTF-8"); // 私钥 BigInteger modulus = new BigInteger("00af9133ade333df8b9aabd776334d0d8f5d96597fe2041fff716185305934cc7a386ab451f28156730ce8a76adcf9bf93ffc87fa47c0d60c4652f1700f50304997a20563cc854f1f84c921f9b1f72d0d3e989d4b22669014859135e89ced24bbac3af1d1a4a76ff5736f81fdc461d2f96cebc5f36eacae7981e7ea59443448fa1", 16); BigInteger privateExponent = new BigInteger("009c46140920e6c881bc405f7e1ff5e32f0cafcaa4912af8cc6840d4cc0f6b76e3079abb3d022dec246686249773707efd9ebcfa19102edc46948650e49232888116e4b54fe77b6eaf5061db4f50c89646241559f602d477efb0d6b755a67a40e978753f56d16142660c47bc91408cf01deaaf3f30180050e2730980e9498cdd3d", 16); RSAPrivateKeySpec privateKeySpec = new RSAPrivateKeySpec(modulus, privateExponent); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec); //用SHA-256做摘要 MessageDigest md= MessageDigest.getInstance("SHA-256"); data=md.digest(data); // 签名 Signature instance = Signature.getInstance("SHA1withRSA"); instance.initSign(privateKey); instance.update(data); byte[] sing = instance.sign(); System.out.println(byteArr2HexString(sing)); } // 以下为调用到的公共方法 public static String byteArr2HexString(byte[] bytearr) { if (bytearr == null) { return "null"; } StringBuffer sb = new StringBuffer(); for (int k = 0; k < bytearr.length; k++) { if ((bytearr[k] & 0xFF) < 16) { sb.append("0"); } sb.append(Integer.toString(bytearr[k] & 0xFF, 16)); } return sb.toString(); } }

PHP RSA加密字符串的Android设备解密失败,解密结果不正确

<div class="post-text" itemprop="text"> <p>The code that encrypts a string PHP-serverside. I use the PKCS8 and not PKCS1 so that I can unencrypt on Android side.</p> <p>The code for the Encryption follows: I use the phpseclib.</p> <pre><code>include('libs/PHPSecLib/Crypt/RSA.php'); </code></pre> <p>...code to lookup public and private keys stored in database omitted...</p> <pre><code>$rsa = new Crypt_RSA(); $rsa-&gt;loadKey($row['pref_pub_key']); // public key stored in MySQL BLOB. $plaintext = 'Testing 123'; $rsa-&gt;setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS8); //USE PKCS8 $ciphertext = $rsa-&gt;encrypt($plaintext); echo $ciphertext; $rsa-&gt;loadKey($row['pref_priv_key']); // private key stored in MySQL BLOB echo $rsa-&gt;decrypt($ciphertext); $query = "UPDATE preferences SET pref_license = ?; //execute query to store the encrypted text in pref_license BLOB field. try { $stmt = $db-&gt;prepare($query); $stmt-&gt;bindParam(1,$ciphertext); $stmt-&gt;bindParam(2,$ref); $db-&gt;errorInfo(); $result = $stmt-&gt;execute(); } catch (PDOException $ex) { $response["success"] = 0; $response["message"] = "Database Error. Couldn't update Pref post with License!" . $ex-&gt;getMessage(); echo $response["message"]; die(json_encode($response)); } </code></pre> <p>I basically encrypt the string, and store it in a BLOB field, for later reference.</p> <p>I generate the Private Public KEYPAIR and store in BLOB in the following manner, and send the privatekey to the Android device:</p> <pre><code>include('libs/PHPSecLib/Crypt/RSA.php'); $rsa = new Crypt_RSA(); $rsa-&gt;setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS8); $rsa-&gt;setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS8); extract($rsa-&gt;createKey()); //echo $privatekey . '&lt;br/&gt;&lt;br/&gt;' . $publickey; //I can see that it worked! if (!empty($_POST)) { //initial update query to store the keys in BLOBS on SERVER MYSQL $query = "UPDATE preferences SET pref_priv_key = ?, pref_pub_key = ? WHERE pref_device_serial = ?"; //execute query try { $stmt = $db-&gt;prepare($query); $stmt-&gt;bindParam(1,$privatekey); $stmt-&gt;bindParam(2,$publickey); $stmt-&gt;bindParam(3,$_POST['p_device_serial']); $db-&gt;errorInfo(); $result = $stmt-&gt;execute(); } catch (PDOException $ex) { $response["success"] = 0; $response["message"] = "Database Error. Couldn't update Pref post!" . $ex-&gt;getMessage(); die(json_encode($response)); } } //then I send the $privatekey to the Android device and save it there. //to then later decrypt the serverside encrypted string. $response["success"] = 1; $response["pk"] = $privatekey; $response["message"] = "Key Pair successfully generated."; echo json_encode($response); </code></pre> <p>On the Android device, I use ans AsyncTask to request the Encrypted String and then read the PrivateKey from the local sqlite blob field, and try and decrypt the string:</p> <pre><code> class GetLicense extends AsyncTask&lt;String, String, String&gt; { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(LicenseActivity.this); pDialog.setMessage("Retrieving License Data..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } @Override protected String doInBackground(String... args) { int success; String elicense; try { getPref = LicenseActivity.this.openOrCreateDatabase("aaa.db", Context.MODE_PRIVATE, null); Cursor c = getPref.rawQuery("SELECT * FROM preferences", null); Log.d("request!", "starting"); if (c != null) { if (c.moveToFirst()) { do { String Preferences_Id = c.getString(c.getColumnIndex(SupaAttendDb.KEY_ROWID)); String Preferences_UUID = c.getString(c.getColumnIndex(SupaAttendDb.KEY_Preferences_PREFUUID)); String Preferences_Device_Serial = c.getString(c.getColumnIndex(SupaAttendDb.KEY_Preferences_PREFDEVICESERIAL)); sPK = c.getString(c.getColumnIndex(SupaAttendDb.KEY_Preferences_PREFPK)); // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("p_uuid", Preferences_UUID)); try { //Get Encrypted License from server JSONObject json = jsonParser.makeHttpRequest( GET_LICENSE_URL, "POST", params); // full json response // json success element success = json.getInt(TAG_SUCCESS); if (success == 1) { sData = json.getString(TAG_LICENSE); </code></pre> <p>..then I save the the license to Android SQLite. code not required ... In the onPostExecute, I format the PrivateKey and then try to decrypt the sData, but get the incorrect data back, and not 'Testing 123'.</p> <pre><code> protected void onPostExecute(String file_url) { pDialog.dismiss(); String privKeyPEM = sPK.replace("-----BEGIN PRIVATE KEY----- ", ""); privKeyPEM = privKeyPEM.replace("-----END PRIVATE KEY-----", ""); byte[] b = Base64.decode(privKeyPEM,Base64.DEFAULT); KeyFactory keyFactory = null; try { keyFactory = KeyFactory.getInstance("RSA"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(b); //This decodes properly without any exceptions. PrivateKey privateKey2 = null; try { privateKey2 = keyFactory.generatePrivate(privateKeySpec); } catch (InvalidKeySpecException e) { e.printStackTrace(); } byte[] decryptedData = null; Cipher cipher = null; try { cipher = Cipher.getInstance("RSA"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } try { cipher.init(Cipher.DECRYPT_MODE,privateKey2); } catch (InvalidKeyException e) { e.printStackTrace(); } byte[] sD = Base64.decode(sData, Base64.DEFAULT);// Here I try to get the encrypted string retrieved from server into a byte[]. try { decryptedData = cipher.doFinal(sD); // no errors, but I get the incorrect unencrypted string. } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } if (decryptedData != null){ String decrypted = new String(decryptedData); //decryptedData = Base64.encode(decryptedData,Base64.DEFAULT); Toast.makeText(LicenseActivity.this, decrypted, Toast.LENGTH_LONG).show(); } } } </code></pre> <p>I realise I'm just doing something stupid in this last bit of code where I try and decode the Encrypted string, and then decrypt it. Hope you can point me in the correct direction, and sorry for being long winded.</p> <p>Oh and yes, before you ask, I retrieve the license from the server with the following PHP:</p> <pre><code>require("config.inc.php"); if (!empty($_POST)) { //initial query $query = "SELECT pref_uuid, pref_license, pref_device_serial FROM preferences WHERE pref_uuid = :p_uuid"; $query_params = array(':p_uuid' =&gt; $_POST['p_uuid']); //execute query try { $stmt = $db-&gt;prepare($query); $db-&gt;errorInfo(); $result = $stmt-&gt;execute($query_params); } catch (PDOException $ex) { $response["success"] = 0; $response["message"] = "Database Error. Couldn't retrieve License details!" . $ex-&gt;getMessage(); die(json_encode($response)); } if(!$result) { $response["success"] = 0; $response["message"] = "Database Error. Couldn't return Licenses!" . $ex-&gt;getMessage(); die(json_encode($response)); } $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC); $response["license"] = base64_encode($row['pref_license']); // I encode it here before I send the encrypted string off to android device. $response["message"] = "License Record successfully retrieved"; $response["success"] = 1; echo json_encode($response); } </code></pre> </div>

加密/解密会导致字符串开头的替换和不正确的字符

<div class="post-text" itemprop="text"> <p>Here are my encrypt and decrypt functions</p> <pre><code>public function encrypt($text){ $key = hash("md5", KEY); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_TWOFISH, MCRYPT_MODE_CBC), MCRYPT_RAND); $result = base64_encode(mcrypt_encrypt(MCRYPT_TWOFISH, $key, $text, MCRYPT_MODE_CBC, $iv)); return $result; } public function decrypt($text){ $key = hash("md5", KEY); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_TWOFISH, MCRYPT_MODE_CBC), MCRYPT_RAND); $result = trim(mcrypt_decrypt(MCRYPT_TWOFISH, $key, base64_decode($text), MCRYPT_MODE_CBC, $iv)); return $result; } </code></pre> <p>When encryption is run on a JSON string to be stored as a text file and then retrieved and decrypted the front section of the resulting string has replacement and/or incorrect characters:</p> <p><strong>Expected:</strong></p> <blockquote> <p>{"players":[{"label":"...</p> </blockquote> <p><strong>Actual:</strong></p> <blockquote> <p>�Ӹ�!G@${�W�Rՙ�bel":"...</p> </blockquote> <p>If it makes any difference the actual placement/incorrect chars are different each time I refresh the page on the same file.</p> </div>

使用openssl_public_encrypt加密的数据每次都不同?

<div class="post-text" itemprop="text"> <p>why is the content of $encrypted every time different? </p> <pre><code>// aquire public key from server $server_public_key = openssl_pkey_get_public(file_get_contents("C:\publickey.pem")); // rsa encrypt openssl_public_encrypt("123", $encrypted, $server_public_key); </code></pre> <hr> <p>also I have tried this one</p> <pre><code>$publicKey = "file://C:/publickey.pem"; $privateKey = "file://C:/privatekey.pem"; $plaintext = "String to encrypt"; openssl_public_encrypt($plaintext, $encrypted, $publicKey); $transfer = base64_encode($encrypted); openssl_private_decrypt($encrypted, $decrypted, $privateKey); echo $transfer; //encrypted string </code></pre> <p>and $transfer is everytime a different string:...</p> <p>Z1xyMUquARxcGjqjjSHNAm41CnHI02GXxLyFivvta8YhDkhRJdD4i3kx+8GElljdiSY/NMF9UD3ritWMLGmscdq/QyIf+geYxJFePNd1dNWg+V6zbAKRLaEpsU+aB87jiM/GjytLEkI63dku02BS0ZBgz9UZw/FDNaynV5bTTDM=</p> <p>mRgLPsPtMoV9la7zzuU+cLzS5xMDp7QUmH6Iv4Sv4/FNjt62zcv9ZMWkfG3uVhS8Z1UDtGl+met1CYjBTcfjHCR6hahbwOkTCICXtkRQcc371vURW04XhQzMNgIIbvN5BBdmIyYI6alrS2vKUq7b3T0h8sJf36zh5CynYzyDCFU=</p> <p>G5FhMoJGiUwEBvEOeZpDDrEXdxbWX5iaJ6F+VdYJ3CURPRMftskZNlDhat8gA5V0G+3nXVQZptkHjxMkOqPlmwJHjgIqAiFppHLpEKohyT9qNwkAR00Y6PiWrNUJPiEIZqXHAb8TS0AA0Quhc0UAwcc+I8NGOD59k8BrZE6Z5Ew=</p> </div>

java做易宝支付,所有银行支付通道关闭!

![图片说明](https://img-ask.csdn.net/upload/201906/04/1559649020_753493.jpg) ``` (PaymentUtil工具类) public class PaymentUtil { private static String encodingCharset = "UTF-8"; /** * 生成hmac方法 * * @param p0_Cmd 业务类型 * @param p1_MerId 商户编号 * @param p2_Order 商户订单号 * @param p3_Amt 支付金额 * @param p4_Cur 交易币种 * @param p5_Pid 商品名称 * @param p6_Pcat 商品种类 * @param p7_Pdesc 商品描述 * @param p8_Url 商户接收支付成功数据的地址 * @param p9_SAF 送货地址 * @param pa_MP 商户扩展信息 * @param pd_FrpId 银行编码 * @param pr_NeedResponse 应答机制 * @param keyValue 商户密钥(公司密钥) * @return */ //此方法把原文参数全部放入StringBuilder封装数据 public static String buildHmac(String p0_Cmd,String p1_MerId, String p2_Order, String p3_Amt, String p4_Cur,String p5_Pid, String p6_Pcat, String p7_Pdesc,String p8_Url, String p9_SAF,String pa_MP,String pd_FrpId, String pr_NeedResponse,String keyValue) { StringBuilder sValue = new StringBuilder(); // 业务类型 sValue.append(p0_Cmd); // 商户编号 sValue.append(p1_MerId); // 商户订单号 sValue.append(p2_Order); // 支付金额 sValue.append(p3_Amt); // 交易币种 sValue.append(p4_Cur); // 商品名称 sValue.append(p5_Pid); // 商品种类 sValue.append(p6_Pcat); // 商品描述 sValue.append(p7_Pdesc); // 商户接收支付成功数据的地址 sValue.append(p8_Url); // 送货地址 sValue.append(p9_SAF); // 商户扩展信息 sValue.append(pa_MP); // 银行编码 sValue.append(pd_FrpId); // 应答机制 sValue.append(pr_NeedResponse); //调用易宝工具类加密算法,对所有原文进行加密,返回密文(公司密钥) return PaymentUtil.hmacSign(sValue.toString(), keyValue); } /** * 返回校验hmac方法 * * @param hmac 支付网关发来的加密验证码 * @param p1_MerId 商户编号 * @param r0_Cmd 业务类型 * @param r1_Code 支付结果 * @param r2_TrxId 易宝支付交易流水号 * @param r3_Amt 支付金额 * @param r4_Cur 交易币种 * @param r5_Pid 商品名称 * @param r6_Order 商户订单号 * @param r7_Uid 易宝支付会员ID * @param r8_MP 商户扩展信息 * @param r9_BType 交易结果返回类型 * @param keyValue 密钥 * @return */ public static boolean verifyCallback(String hmac, String p1_MerId, String r0_Cmd, String r1_Code, String r2_TrxId, String r3_Amt, String r4_Cur, String r5_Pid, String r6_Order, String r7_Uid, String r8_MP, String r9_BType, String keyValue) { StringBuilder sValue = new StringBuilder(); // 商户编号 sValue.append(p1_MerId); // 业务类型 sValue.append(r0_Cmd); // 支付结果 sValue.append(r1_Code); // 易宝支付交易流水号 sValue.append(r2_TrxId); // 支付金额 sValue.append(r3_Amt); // 交易币种 sValue.append(r4_Cur); // 商品名称 sValue.append(r5_Pid); // 商户订单号 sValue.append(r6_Order); // 易宝支付会员ID sValue.append(r7_Uid); // 商户扩展信息 sValue.append(r8_MP); // 交易结果返回类型 sValue.append(r9_BType); String sNewString = PaymentUtil.hmacSign(sValue.toString(), keyValue); return sNewString.equals(hmac); } /** * @param aValue * @param aKey * @return */ //把原文和公司密钥传入hmacSign方法进行算法加密得到密文(字符串) public static String hmacSign(String aValue, String aKey) { byte k_ipad[] = new byte[64]; byte k_opad[] = new byte[64]; byte keyb[]; byte value[]; try { keyb = aKey.getBytes(encodingCharset); value = aValue.getBytes(encodingCharset); } catch (UnsupportedEncodingException e) { keyb = aKey.getBytes(); value = aValue.getBytes(); } Arrays.fill(k_ipad, keyb.length, 64, (byte) 54); Arrays.fill(k_opad, keyb.length, 64, (byte) 92); for (int i = 0; i < keyb.length; i++) { k_ipad[i] = (byte) (keyb[i] ^ 0x36); k_opad[i] = (byte) (keyb[i] ^ 0x5c); } MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return null; } md.update(k_ipad); md.update(value); byte dg[] = md.digest(); md.reset(); md.update(k_opad); md.update(dg, 0, 16); dg = md.digest(); return toHex(dg); } public static String toHex(byte input[]) { if (input == null) return null; StringBuffer output = new StringBuffer(input.length * 2); for (int i = 0; i < input.length; i++) { int current = input[i] & 0xff; if (current < 16) output.append("0"); output.append(Integer.toString(current, 16)); } return output.toString(); } /** * * @param args * @param key * @return */ public static String getHmac(String[] args, String key) { if (args == null || args.length == 0) { return (null); } StringBuffer str = new StringBuffer(); for (int i = 0; i < args.length; i++) { str.append(args[i]); } return (hmacSign(str.toString(), key)); } /** * @param aValue * @return */ public static String digest(String aValue) { aValue = aValue.trim(); byte value[]; try { value = aValue.getBytes(encodingCharset); } catch (UnsupportedEncodingException e) { value = aValue.getBytes(); } MessageDigest md = null; try { md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } return toHex(md.digest(value)); } // public static void main(String[] args) { // System.out.println(hmacSign("AnnulCard1000043252120080620160450.0http://localhost/SZXpro/callback.asp杩?4564868265473632445648682654736324511","8UPp0KE8sq73zVP370vko7C39403rtK1YwX40Td6irH216036H27Eb12792t")); // } } merchantInfo.properties(配置文件) p1_MerId=10001126856 keyValue=69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl responseURL=http://api.ecps.com:8080/OrderServlet?method=callback (OrderServlet) @WebServlet(urlPatterns = "/OrderServlet") public class OrderServlet extends BaseServlet { //支付,请求方法 public void pay(HttpServletRequest request,HttpServletResponse response) throws Exception{ // 接受参数 String address=request.getParameter("address"); String name=request.getParameter("name"); String telephone=request.getParameter("telephone"); String oid=request.getParameter("oid"); // 调用业务层方法,更新订单信息 ordersService.updateOrder(name,address,telephone,oid); // 组织发送支付公司需要哪些数据 String pd_FrpId = request.getParameter("pd_FrpId"); String p0_Cmd = "Buy"; String p1_MerId = ResourceBundle.getBundle("merchantInfo").getString("p1_MerId"); String p2_Order = oid; String p3_Amt = "0.01"; String p4_Cur = "CNY"; String p5_Pid = ""; String p6_Pcat = ""; String p7_Pdesc = ""; // 支付成功回调地址 ---- 第三方支付公司会访问、用户访问 // 第三方支付可以访问网址 String p8_Url = ResourceBundle.getBundle("merchantInfo").getString("responseURL"); String p9_SAF = ""; String pa_MP = ""; String pr_NeedResponse = "1"; // 加密hmac 需要密钥 String keyValue = ResourceBundle.getBundle("merchantInfo").getString("keyValue"); // 传入回调地址 String hmac = PaymentUtil.buildHmac(p0_Cmd, p1_MerId, p2_Order, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse, keyValue); // 发送给第三方 StringBuffer sb = new StringBuffer("https://www.yeepay.com/app-merchant-proxy/node?"); sb.append("p0_Cmd=").append(p0_Cmd).append("&"); sb.append("p1_MerId=").append(p1_MerId).append("&"); sb.append("p2_Order=").append(p2_Order).append("&"); sb.append("p3_Amt=").append(p3_Amt).append("&"); sb.append("p4_Cur=").append(p4_Cur).append("&"); sb.append("p5_Pid=").append(p5_Pid).append("&"); sb.append("p6_Pcat=").append(p6_Pcat).append("&"); sb.append("p7_Pdesc=").append(p7_Pdesc).append("&"); sb.append("p8_Url=").append(p8_Url).append("&"); sb.append("p9_SAF=").append(p9_SAF).append("&"); sb.append("pa_MP=").append(pa_MP).append("&"); sb.append("pd_FrpId=").append(pd_FrpId).append("&"); sb.append("pr_NeedResponse=").append(pr_NeedResponse).append("&"); sb.append("hmac=").append(hmac); // Ajax跨域请求不能使用重定向,不能使用转发 // respone.sendRedirect(sb.toString()); //把sb的数据封装到JSON响应会页面 Result re = new Result(Result.SUCCESS,"",sb.toString()); response.getWriter().print(JSONObject.fromObject(re)); // return null; } /*callBack 获取易宝数据,并做比较.数据是否有效,有效则支付成功,支付后的回调方法*/ public String callback(HttpServletRequest request,HttpServletResponse response) throws Exception{ String p1_MerId = request.getParameter("p1_MerId"); String r0_Cmd = request.getParameter("r0_Cmd"); String r1_Code = request.getParameter("r1_Code"); String r2_TrxId = request.getParameter("r2_TrxId"); String r3_Amt = request.getParameter("r3_Amt"); String r4_Cur = request.getParameter("r4_Cur"); String r5_Pid = request.getParameter("r5_Pid"); String r6_Order = request.getParameter("r6_Order"); String r7_Uid = request.getParameter("r7_Uid"); String r8_MP = request.getParameter("r8_MP"); String r9_BType = request.getParameter("r9_BType"); String rb_BankId = request.getParameter("rb_BankId"); String ro_BankOrderId = request.getParameter("ro_BankOrderId"); String rp_PayDate = request.getParameter("rp_PayDate"); String rq_CardNo = request.getParameter("rq_CardNo"); String ru_Trxtime = request.getParameter("ru_Trxtime"); // 身份校验 --- 判断是不是支付公司通知你 String hmac = request.getParameter("hmac"); String keyValue = ResourceBundle.getBundle("merchantInfo").getString( "keyValue"); // 自己对上面数据进行加密 --- 比较支付公司发过来hamc boolean isValid = PaymentUtil.verifyCallback(hmac, p1_MerId, r0_Cmd, r1_Code, r2_TrxId, r3_Amt, r4_Cur, r5_Pid, r6_Order, r7_Uid, r8_MP, r9_BType, keyValue); //判断数据是否有效 if (isValid) { // 响应数据有效 if (r9_BType.equals("1")) { // 浏览器重定向 System.out.println("111"); request.setAttribute("msg", "您的订单号为:"+r6_Order+",金额为:"+r3_Amt+"已经支付成功,等待发货~~"); } else if (r9_BType.equals("2")) { // 修改订单状态: // 服务器点对点 --- 支付公司通知你 System.out.println("付款成功!222"); // 修改订单状态 为已付款 // 回复支付公司success,如果不回复,支付公司会一直通知 response.getWriter().print("success"); } //订单状态,更新订单状态为已经付款 ordersService.updateOrderState(r6_Order); } else { // 数据无效 System.out.println("数据被篡改!"); } return "/jsp/msg.jsp"; } ```

C#窗口程序调用快递鸟API查询快递完整源码

请大神帮忙C#实现点击按钮用户输入快递单号和快递公司,调用快递鸟API查询快递物流信息,将结果输出到文本框中 以下是快递鸟Demo ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Net; using System.IO; namespace KdGoldAPI { public class KdApiSearchDemo { //电商ID private string EBusinessID = "xxxxxxxxxxx"; //电商加密私钥,快递鸟提供,注意保管,不要泄漏 private string AppKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; //请求url private string ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"; /// <summary> /// Json方式 查询订单物流轨迹 /// </summary> /// <returns></returns> public string getOrderTracesByJson() { string requestData = "{'OrderCode':'','ShipperCode':'SF','LogisticCode':'589707398027'}"; Dictionary<string, string> param = new Dictionary<string, string>(); param.Add("RequestData", HttpUtility.UrlEncode(requestData, Encoding.UTF8)); param.Add("EBusinessID", EBusinessID); param.Add("RequestType", "1002"); string dataSign = encrypt(requestData, AppKey, "UTF-8"); param.Add("DataSign", HttpUtility.UrlEncode(dataSign, Encoding.UTF8)); param.Add("DataType", "2"); string result = sendPost(ReqURL, param); //根据公司业务处理返回的信息...... return result; } /// <summary> /// Post方式提交数据,返回网页的源代码 /// </summary> /// <param name="url">发送请求的 URL</param> /// <param name="param">请求的参数集合</param> /// <returns>远程资源的响应结果</returns> private string sendPost(string url, Dictionary<string, string> param) { string result = ""; StringBuilder postData = new StringBuilder(); if (param != null && param.Count > 0) { foreach (var p in param) { if (postData.Length > 0) { postData.Append("&"); } postData.Append(p.Key); postData.Append("="); postData.Append(p.Value); } } byte[] byteData = Encoding.GetEncoding("UTF-8").GetBytes(postData.ToString()); try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Referer = url; request.Accept = "*/*"; request.Timeout = 30 * 1000; request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"; request.Method = "POST"; request.ContentLength = byteData.Length; Stream stream = request.GetRequestStream(); stream.Write(byteData, 0, byteData.Length); stream.Flush(); stream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream backStream = response.GetResponseStream(); StreamReader sr = new StreamReader(backStream, Encoding.GetEncoding("UTF-8")); result = sr.ReadToEnd(); sr.Close(); backStream.Close(); response.Close(); request.Abort(); } catch (Exception ex) { result = ex.Message; } return result; } ///<summary> ///电商Sign签名 ///</summary> ///<param name="content">内容</param> ///<param name="keyValue">Appkey</param> ///<param name="charset">URL编码 </param> ///<returns>DataSign签名</returns> private string encrypt(String content, String keyValue, String charset) { if (keyValue != null) { return base64(MD5(content + keyValue, charset), charset); } return base64(MD5(content, charset), charset); } ///<summary> /// 字符串MD5加密 ///</summary> ///<param name="str">要加密的字符串</param> ///<param name="charset">编码方式</param> ///<returns>密文</returns> private string MD5(string str, string charset) { byte[] buffer = System.Text.Encoding.GetEncoding(charset).GetBytes(str); try { System.Security.Cryptography.MD5CryptoServiceProvider check; check = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] somme = check.ComputeHash(buffer); string ret = ""; foreach (byte a in somme) { if (a < 16) ret += "0" + a.ToString("X"); else ret += a.ToString("X"); } return ret.ToLower(); } catch { throw; } } /// <summary> /// base64编码 /// </summary> /// <param name="str">内容</param> /// <param name="charset">编码方式</param> /// <returns></returns> private string base64(String str, String charset) { return Convert.ToBase64String(System.Text.Encoding.GetEncoding(charset).GetBytes(str)); } } ```

学Python后到底能干什么?网友:我太难了

感觉全世界营销文都在推Python,但是找不到工作的话,又有哪个机构会站出来给我推荐工作? 笔者冷静分析多方数据,想跟大家说:关于超越老牌霸主Java,过去几年间Python一直都被寄予厚望。但是事实是虽然上升趋势,但是国内环境下,一时间是无法马上就超越Java的,也可以换句话说:超越Java只是时间问题罢。 太嚣张了会Python的人!找工作拿高薪这么简单? https://edu....

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

为什么程序猿都不愿意去外包?

分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助

Java校招入职华为,半年后我跑路了

何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

@程序员:GitHub这个项目快薅羊毛

今天下午在朋友圈看到很多人都在发github的羊毛,一时没明白是怎么回事。 后来上百度搜索了一下,原来真有这回事,毕竟资源主义的羊毛不少啊,1000刀刷爆了朋友圈!不知道你们的朋友圈有没有看到类似的消息。 这到底是啥情况? 微软开发者平台GitHub 的一个区块链项目 Handshake ,搞了一个招募新会员的活动,面向GitHub 上前 25万名开发者派送 4,246.99 HNS币,大约价...

用python打开电脑摄像头,并把图像传回qq邮箱【Pyinstaller打包】

前言: 如何悄悄的打开朋友的摄像头,看看她最近过的怎么样,嘿嘿!这次让我带你们来实现这个功能。 注: 这个程序仅限在朋友之间开玩笑,别去搞什么违法的事情哦。 代码 发送邮件 使用python内置的email模块即可完成。导入相应的代码封装为一个send函数,顺便导入需要导入的包 注: 下面的代码有三处要修改的地方,两处写的qq邮箱地址,还有一处写的qq邮箱授权码,不知道qq邮箱授权码的可以去百度一...

C++(继承):19---虚基类与虚继承(virtual)

一、菱形继承 在介绍虚继承之前介绍一下菱形继承 概念:A作为基类,B和C都继承与A。最后一个类D又继承于B和C,这样形式的继承称为菱形继承 菱形继承的缺点: 数据冗余:在D中会保存两份A的内容 访问不明确(二义性):因为D不知道是以B为中介去访问A还是以C为中介去访问A,因此在访问某些成员的时候会发生二义性 缺点的解决: 数据冗余:通过下面“虚继承”技术来解决(见下) 访问...

计算机网络——浅析网络层

一、前言 注意,关于ipv4和ipv6,ipv4是ip协议第4版本,也表示这个版本的ip一共4个字节,同样地,ipv6是ip协议第6版本,也表示这个版本的ip一共6个字节。 关于网络层使用路由器实现互联:在计算机网络的分层结构中,不同层有不同的中继设备: 计算机网络层 中继设备/中继系统 物理层 中继器、集线器Hub 数据链路层 网桥或交换机(交换机是多端口网桥,两者本质上是一个东西) 网络层 路...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

女朋友过生日,我花了20分钟给她写了一个代理服务器

女朋友说:“看你最近挺辛苦的,我送你一个礼物吧。你看看想要什么,我来准备。” 我想了半天,从书到鞋子到电子产品最后到生活用品,感觉自己什么都不缺,然后和她说:“你省省钱吧,我什么都不需要。” 她坚持要送:“不行,你一定要说一个礼物,我想送你东西了。” 于是,我认真了起来,拿起手机,上淘宝逛了几分钟,但还是没能想出来缺点什么,最后实在没办法了:“这样吧,如果你实在想送东西,那你就写一个代理服务器吧”...

记一次腾讯面试,我挂在了最熟悉不过的队列上……

腾讯后台面试,面试官问:如何自己实现队列?

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

立即提问
相关内容推荐