Recent

Author Topic: d  (Read 1213 times)

fpc2pas

  • New Member
  • *
  • Posts: 34
d
« on: March 27, 2022, 07:29:27 am »
[]
« Last Edit: March 27, 2022, 01:04:44 pm by fpc2pas »

AlexTP

  • Hero Member
  • *****
  • Posts: 2400
    • UVviewsoft
Re: XOR array of bytes
« Reply #1 on: March 27, 2022, 09:16:58 am »
Make the type of array

  PMy = ^TMy;
  TMy = packed array[0..1000*1000] of byte;

Make the xor procedure, which takes param of PMy.
Then cast any pointer to PMy.


af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: XOR array of bytes
« Reply #2 on: March 27, 2022, 09:34:16 am »
The array holds Bytes, not more not less. The hexadecimal notation is only a visual representation in the code. If you write $fe it will the same as you write 254 .

See here done with CRC under Pascal/Delphi with word https://de.wikipedia.org/wiki/Zyklische_Redundanzpr%C3%BCfung
« Last Edit: March 27, 2022, 09:36:05 am by af0815 »
regards
Andreas

fpc2pas

  • New Member
  • *
  • Posts: 34
Re: XOR array of bytes
« Reply #3 on: March 27, 2022, 10:03:54 am »
thanks guys it has been solved for now  O:-)

Thaddy

  • Hero Member
  • *****
  • Posts: 14358
  • Sensorship about opinions does not belong here.
Re: XOR array of bytes
« Reply #4 on: March 27, 2022, 11:24:22 am »
Note such a task is for real beginners with less than three days of any programming experience at all. I will bet that 99%+ of the forum members have at some point implemented XOR obfuscation. Even with passwords and recurring sequences... >:D
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: XOR array of bytes
« Reply #5 on: March 27, 2022, 11:49:58 am »
I don't understand why questioners always have to be insulted here.
Is this some kind of obsessive-compulsive disorder?

Apart from anything else it's a strong hint that without much more information anybody who uses "xor" and "encryption" in the same sentence might be living dangerously.

I'd add that a more robust description of the problem is in order. I'm afraid that I'm somewhat dubious about Alex's suggestion of a pointer and cast: if the array is guaranteed to be a fixed size (e.g. a block from a file or received via a comms protocol) then an appropriate type of that size should be defined together with an appropriate function or procedure operating on that type: without that there's a risk of losing all the advantages of Pascal's strong type checking.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

440bx

  • Hero Member
  • *****
  • Posts: 4014
Re: XOR array of bytes
« Reply #6 on: March 27, 2022, 01:09:48 pm »
I don't understand why questioners always have to be insulted here.
Is this some kind of obsessive-compulsive disorder?
I think some people (seems to always be the same "people") have bad memory and forgot that they, at one time, were beginners too and asked questions that experienced people thought trivial yet, very often they got it answered and quite often with a luxurious explanation.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: d
« Reply #7 on: March 27, 2022, 01:25:18 pm »
Now that the OP has vandalised this whole thread, I’m locking it and have banned him.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
[Original post] XOR array of bytes
« Reply #8 on: March 27, 2022, 02:21:24 pm »
Hi folks

wondering how to use xor encryption/decryption for an array of bytes, an array of bytes contains hexadecimal values such as $fc,$e4 ..etc.

any ideas?

[Restored original post]

 

TinyPortal © 2005-2018