|
Помогите перевести код из C# в 1С | ☑ | ||
---|---|---|---|---|
0
Tutoff
16.12.17
✎
06:46
|
Здравствуйте!
Очень туго знаком с другими языками, а на 1С не доводилось проходить такую процедуру никогда. Код авторизации и POST запроса на C# (доступен и на других языках: ПХП, Ява и тд.) string apiKey = "key"; string apiSecret = "secret"; string requestUri = "https://www.aaa.ru/api/uriZapros"; var postData = new { StateInp = "InpID" }; // Create Request var request = new HttpRequestMessage(); request.Method = HttpMethod.Post; request.RequestUri = new Uri(requestUri); request.Content = new ObjectContent(typeof(object), postData, new JsonMediaTypeFormatter()); // Authentication string requestContentBase64String = string.Empty; if (request.Content != null) { // Hash content to ensure message integrity using (var md5 = MD5.Create()) { requestContentBase64String = Convert.ToBase64String(md5.ComputeHash(await request.Content.ReadAsByteArrayAsync())); } } //create random nonce for each request var nonce = Guid.NewGuid().ToString("N"); //Creating the raw signature string var signature = Encoding.UTF8.GetBytes(string.Concat(apiKey, HttpMethod.Post, HttpUtility.UrlEncode(request.RequestUri.AbsoluteUri.ToLower()), nonce, requestContentBase64String)); using (var hmac = new HMACSHA256(Convert.FromBase64String(apiSecret))) { request.Headers.Authorization = new AuthenticationHeaderValue("amx", string.Format("{0}:{1}:{2}", apiKey, Convert.ToBase64String(hmac.ComputeHash(signature)), nonce)); } //////////////////////// Вот это чудо. Запутался уже совсем. |
|||
1
DDwe
16.12.17
✎
07:06
|
(0) Тебе оно зачем?
|
|||
2
Tutoff
16.12.17
✎
07:31
|
Торговый робот. С С# на 1С переехать хочу.
|
|||
3
Tarzan_Pasha
16.12.17
✎
07:50
|
упал с этажа.
|
|||
4
DDwe
16.12.17
✎
08:00
|
(2) Переезжай.
|
|||
5
Tutoff
16.12.17
✎
08:15
|
Спасибо.
|
|||
6
DDwe
16.12.17
✎
08:34
|
ТС интересный такой, ни в языках не понимает, ни в программировании... переведите ему )))
|
|||
7
Tutoff
16.12.17
✎
09:17
|
Да мне только с подписью HMACSHA256 не понятно, а остальное сделано.
|
|||
8
Tutoff
16.12.17
✎
09:43
|
hmacsignature = base64.b64encode(hmac.new(base64.b64decode( API_SECRET ), signature, hashlib.sha256).digest())
Вот такое как сделать? |
|||
9
DDwe
16.12.17
✎
09:45
|
(8) Сделать что?
|
|||
10
Tutoff
16.12.17
✎
09:53
|
В 1С написать. Есть АПИСекрет, есть сигнатура.
Как сделать хмак из них по СХА-256? |
|||
11
Адинэснег
16.12.17
✎
09:55
|
B64 - Base64Строка() из встроенного
HMAC http://catalog.mista.ru/public/591665/ |
|||
12
Tutoff
16.12.17
✎
10:00
|
о как. Спасибо.
|
|||
13
Serginio1
16.12.17
✎
12:50
|
Форум | Правила | Описание | Объявления | Секции | Поиск | Книга знаний | Вики-миста |