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.
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.
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