# Data Scrambler Class & Demo

**URL:** <https://clarionhub.com/t/data-scrambler-class-demo/5561>\
**Category:** code\
**Tags:** class, github\
**Created:** [October 25, 2022, 2:11am UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561 "2022-10-25T02:11:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [October 25, 2022, 2:11am UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/1 "2022-10-25T02:11:06Z")

</div>

I pushed a new repo to Github, for scrambling data.

The demo requires C10 or higher, but some of the earlier C10 versions might not be able to compile it because of the differences in SystemStringClass over the course of C10's releases.

I'll try to make a demo that will work for earlier versions when I get a chance.

> **[GitHub - jslarve/AmbleScrayLite: Scramble text by way of a password](https://github.com/jslarve/AmbleScrayLite)**
>
> Scramble text by way of a password

Enjoy

---

<div class="post-metadata">

**Author:** ![donridley](https://clarionhub.com/user_avatar/clarionhub.com/donridley/32/1459_2.png) [@donridley](https://clarionhub.com/u/donridley)\
**Post date:** [October 25, 2022, 11:27am UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/2 "2022-10-25T11:27:45Z")

</div>

Cool! Thank you Jeff!

---

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [October 25, 2022, 11:37am UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/3 "2022-10-25T11:37:17Z")

</div>

This is an interesting comment

> This function is used instead of the built-in Clarion CRC32 for compatibility with other languages

How many different ways can CRC32 work?

[Cyclic redundancy check - Wikipedia](https://en.wikipedia.org/wiki/Cyclic_redundancy_check#CRC-32_algorithm)

I see further down in the link, that it appears there are a number of factors which can alter the result, it seems that the first stage of choice and use of different polynomials can affect the result along with the factors mentioned in the specifications:  
[Cyclic redundancy check - Wikipedia](https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Specification)

[RFC 3385: Internet Protocol Small Computer System Interface (iSCSI) Cyclic Redundancy Check (CRC)/Checksum Considerations (rfc-editor.org)](https://www.rfc-editor.org/rfc/rfc3385)

> We will also attempt to compare Cyclic Redundancy Checks (CRCs) with  
> other checksum forms (e.g., Fletcher, Adler, weighted checksums), as  
> permitted by available data.

[RFC 3309 - Stream Control Transmission Protocol (SCTP) Checksum Change (ietf.org)](https://datatracker.ietf.org/doc/html/rfc3309)

> Stream Control Transmission Protocol (SCTP) currently uses an Adler-  
> 32 checksum. For small packets Adler-32 provides weak detection of  
> errors. This document changes that checksum and updates SCTP to use  
> a 32 bit CRC checksum.

I thought there was only one CRC32, that was universally accepted across the IT world, but it appears not.

This is an interesting answer to a question.  
[hash - CRC32 vs CRC32C? - Stack Overflow](https://stackoverflow.com/questions/26429360/crc32-vs-crc32c)

> CRC32C uses a different polynomial (0x1EDC6F41, reversed 0x82F63B78) but otherwise the computation is the same. The results are different, naturally. This is also known as the Castagnoli CRC32 and most conspicuously found in newer Intel CPUs which can compute a full 32-bit CRC step in 3 cycles. That is the reason why the CRC32C is becoming more popular, since it allows advanced implementations that effectively process one 32-bit word per cycle despite the three-cycle latency (by processing 3 streams of data in parallel and using linear algebra to combine the results).

So is this offering using the CRC32C aka CRC32 Castagnoli , that is a 3 cycle calculation?

Asking for a friend. 😉

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [October 25, 2022, 12:10pm UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/4 "2022-10-25T12:10:59Z")

</div>

> [@anon23294430](#):
>
> So is this offering using the CRC32C aka CRC32 Castagnoli , that is a 3 cycle calculation?

no it is not. It would take many more cycles than that. It was based on some C code I found on the net. It does not have any pre-computed table lookups which are often used to speed things up. But this code is about as fast as I could get while keeping it “simple”.

In case you are interested Richard, I’ve just done a bit of searching and I believe this was my original c code reference:

> <https://github.com/hcs0/Hackers-Delight/blob/master/crc.c.txt>

---

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [October 25, 2022, 8:29pm UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/5 "2022-10-25T20:29:31Z")

</div>

Ok. [Post must be at least 20 characters]

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [November 13, 2022, 11:04pm UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/6 "2022-11-13T23:04:39Z")

</div>

I pushed up some changes to my data scrambler. Added a hex output to the demo and some other changes.

> **[GitHub - jslarve/AmbleScrayLite: Scramble text by way of a password](https://github.com/jslarve/AmbleScrayLite)**
>
> Scramble text by way of a password

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [July 23, 2023, 12:33am UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/7 "2023-07-23T00:33:08Z")

</div>

I pushed a new update to the Clarion class for compatibility with the versions in other languages.

The ScrambleData() and UnScrambleData() methods introduce a new parameter for number of iterations, as well.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [November 21, 2023, 1:05am UTC](https://clarionhub.com/t/data-scrambler-class-demo/5561/8 "2023-11-21T01:05:08Z")

</div>

Over the weekend, I added my first typescript class to npm.  
[https://www.npmjs.com/package/@jslarve/amblescraylite](https://www.npmjs.com/package/@jslarve/amblescraylite)

An example of its use is here: [https://codepen.io/jslarve/pen/abXqENO](https://codepen.io/jslarve/pen/abXqENO)
