S
S
Sergey Sokolov2016-03-03 20:23:20
JavaScript
Sergey Sokolov, 2016-03-03 20:23:20

What simple hash function can be implemented in VkScript?

VKScript is a very stripped-down version of JavaScript that is executed on the VKontakte servers when the execute() API method is called. Supported, I quote:

  • arithmetic operations
  • logical operations
  • creating arrays and lists ([X,Y])
  • parseInt and parseDouble
  • concatenation (+)
  • if construct
  • array filter by parameter (@.)
  • API method calls, length parameter
  • loops using the while statement
  • Javascript methods: slice, push, pop, shift, unshift, splice, substr
  • delete operator
  • assigning array elements, for example: row.user.action = "test";

And no more than 25 VK API method calls. The number of rounds in cycles is also limited. Those. very, very truncated language.
It is necessary to protect a certain parameter transmitted through the client from forgery. It would be just great if I could check some kind of digital signature in this script. Those. on my server, I would calculate a certain hash from the parameter, and check it in this script.
Question : what hash-like function can be implemented in VKScript, and how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2016-03-03
@sergiks

It would be just great if I could check some kind of digital signature in this script. Those. on my server, I would calculate a certain hash from the parameter, and check it in this script.
It's not a digital signature, it's security through obscurity. A digital signature requires asymmetric encryption.
In my opinion, you can implement almost any hash function with this method set. If logical operations include bitwise. And if they do not include - you can implement them through arithmetic. Take something from simple ones, MD5, for example. Or even CRC32.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question