我对加密/散列知之甚少.
我必须哈希加密密钥.Java中的例子是这样的......
String encryptionKey = "test";
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(encryptionKey.getBytes("UTF-8"), 0, encryptionKey.length());
byte[] encryptionKeyBytes = messageDigest.digest();
Run Code Online (Sandbox Code Playgroud)
如果我错了,现在纠正我,但上面的代码用MD5算法对字符串进行哈希处理.
当我在C#中散列相同的字符串时,我想要相同的结果.
我目前的C#代码看起来像这样......
string encryptionKey = "test";
var md5 = MD5.Create();
var keyBytes = Encoding.UTF8.GetBytes(encryptionKey);
byte[] encryptionKeyBytes = md5.ComputeHash(keyBytes);
Run Code Online (Sandbox Code Playgroud)
但结束字节结果不匹配.
Java得到......
[0] 9
[1] -113
[2] 107
[3] -51
[4] 70
[5] 33
[6] -45
[7] 115
[8] -54
[9] -34
[10] 78
[11] -125
[12] 38
[13] 39
[14] -76
[15] -10
Run Code Online (Sandbox Code Playgroud)
C#得到......
[0] 9 byte
[1] 143 byte
[2] 107 byte …Run Code Online (Sandbox Code Playgroud) 我正在从另一个数据库导入数据。
我的过程是将数据从远程数据库导入到List<DataModel>命名的数据库中,并将remoteData数据从本地数据库导入到List<DataModel>命名的localData.
然后我使用 LINQ 创建一个不同的记录列表,以便我可以更新本地数据库以匹配从远程数据库中提取的数据。像这样:
var outdatedData = this.localData.Intersect(this.remoteData, new OutdatedDataComparer()).ToList();
Run Code Online (Sandbox Code Playgroud)
然后我使用 LINQ 创建一个不再存在于remoteData中但确实存在于中的记录列表localData,以便我将它们从本地数据库中删除。
像这样:
var oldData = this.localData.Except(this.remoteData, new MatchingDataComparer()).ToList();
Run Code Online (Sandbox Code Playgroud)
然后我使用 LINQ 执行与上述相反的操作,将新数据添加到本地数据库。
像这样:
var newData = this.remoteData.Except(this.localData, new MatchingDataComparer()).ToList();
Run Code Online (Sandbox Code Playgroud)
每个集合导入大约 70k 条记录,3 个 LINQ 操作中的每一个都需要 5 到 10 分钟才能完成。我怎样才能更快?
这是集合正在使用的对象:
internal class DataModel
{
public string Key1{ get; set; }
public string Key2{ get; set; }
public string Value1{ get; set; }
public string Value2{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用.net Web服务中的方法.
Web服务背后的代码在命名空间的末尾有一个'/'
[WebService(Namespace = "http://www.mynamespace.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
Run Code Online (Sandbox Code Playgroud)
这是.net方法调用
POST /TelematicsWebService/Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.mynamespace.com/GetDevicesByBranch"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDevicesByBranch xmlns="http://www.mynamespace.com/">
<branchNumber>int</branchNumber>
</GetDevicesByBranch>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
现在调用方法的代码看起来像这样
@Override
protected SoapObject doInBackground(Integer... branchNumber) {
final String NAMESPACE = "http://www.mynamespace.com/";
final String METHOD_NAME = "GetDevicesByBranch";
final String SOAP_ACTION = NAMESPACE + METHOD_NAME;
final String URL = "http://10.0.2.2/TelematicsWebService/Service.asmx";
SoapObject response = null;
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo inputArgs = …Run Code Online (Sandbox Code Playgroud) 我有以下 app.js 文件作为主要的 Vue 组件。
import './bootstrap';
import router from './routes';
new Vue({
el: '#app',
router: router
});
Run Code Online (Sandbox Code Playgroud)
我的 bootstrap.js 如下
import Vue from 'vue';
import VueRouter from 'vue-router';
import axios from 'axios';
// Global variable for API access
window.hostname = 'https://city.molotex.ru/cgi-bin/citygate.py?';
// Global variable for VueJS
window.Vue = Vue;
// Vue router
Vue.use(VueRouter);
//Vue Resource
var VueResource = require('vue-resource');
Vue.use(VueResource);
// axios
window.axios = axios;
window._ = require('lodash');
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap-sass');
} catch (e) …Run Code Online (Sandbox Code Playgroud) c# ×2
algorithm ×1
android ×1
collections ×1
hash ×1
java ×1
javascript ×1
linq ×1
md5 ×1
performance ×1
vue-router ×1
vuejs2 ×1
web-services ×1