Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Bit-based functions in 8.3.10

Forum

Search UsersRules
Bit-based functions in 8.3.10
#1
Interested
Points:: 15
Joined:: Oct 27, 2011

1C implemented functions to mask bits and work with binary data. I have tried the new possibilities, but found them quite uncomfortable. I have to write like 20 lines of code for quite a simple bit operations.

How would you implement in 1C:Enterprise script something like:

Code
Result:= (A shr 24) or ((A shr 8) and $FF00) or ((A shl 8) and $FF0000) or (A shl 24)

It is not made up. It is a part of sha-1 calculation.

Profile
#2
Active user
Points:: 0
Joined:: Nov 3, 2011

Alexey,

yes, the implementation of this algorithm in 1C:Enterprise version 8.3.10 is tricky. Having bit shift functions in 1C:Enterprise script would help and reduce your 20 lines to a single one.

I'm sending the request for bit shift functions to the platform development team.

Profile
#3
Interested
Points:: 15
Joined:: Oct 27, 2011

It is not just bit shift functions. Try to implement smth like:

Code
Result:= A or ((A xor D) and $FF00) or A and $FF0000) or (A xor C)

Profile
#4
Just came
Points:: 0
Joined:: Apr 8, 2013

Hi, Alexey,

You can calculate popular cash functions (CRC32, MD5, SHA1, and SHA256) out-of-box.
To find out more look at HashFunction in the syntax assistant.

Profile
#5
Just came
Points:: 0
Joined:: Apr 8, 2013

Julia,

I would like also get native bitwise operations support in the platform to calculate HMAC and other crypto algorithms.

Profile
#6
Active user
Points:: 0
Joined:: Nov 3, 2011

I added logical bitwise operations to the feature request. We definitely need the entire package of bitwise functions.

Profile
#7
Interested
Points:: 15
Joined:: Oct 27, 2011

Anton, Thank you for pointing out HashFunction.

Actually 1c hash functions implementation is quite confusing, because there are HashAlgorithm and it is a part of CryptoManager that does not have good documentation.

And HashFunction is part of DataHashing. It is quite easy to be confused which one is part of which package.

Yulya, I understand why 1c still not implemented bitshift functions. There is no Word, int, dword data types. But still there are quite a lot of examples where I need to read some files with bit masking. Current implementation makes this process quite painful.. look at this code:

Code
Function Mask(Byte, ByteMask)
   MaskNumber = NumberFromBinaryString(ByteMask);
   InputBuffer = BufferFromByte(Byte);
   MaskBuffer = BufferFromByte(MaskNumber);
   InputBuffer.WriteBitwiseAnd(0,MaskBuffer,1);
   Return InputBuffer[0];
EndFunction
   

Function BufferFromByte(Byte)
   Buffer = New BinaryDataBuffer(1);
   Buffer[0] = Byte;
   Return Buffer;
EndFunction

      CurByte = DataReader.ReadByte();
      CurNumber = CurNumber * 128 + Mask(CurByte, "0b01111111");
      If 0=Mask(CurByte, "0b10000000") Then


This is not easy to read code...

Profile
#8
Active user
Points:: 0
Joined:: Nov 3, 2011

Alexey, I understand your pain. That is why I added a feature request and I will keep you informed on its progress.

Profile
#9
Active user
Points:: 0
Joined:: Nov 3, 2011

Good news, everyone! Bitwise operations will make their way to 1C:Enterprise 8.3.11.

Profile
#10
Interested
Points:: 15
Joined:: Oct 27, 2011

Great news! Thanks for keeping us up to date.

Profile
#11
Just came
Points:: 0
Joined:: Aug 11, 2019

salam men 1c 8.3.10 versiyanin pulsuz nece yukliye bilerim ?

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.