summary refs log tree commit diff
path: root/Crypto/src/bcpg/Crc24.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Crypto/src/bcpg/Crc24.cs')
-rw-r--r--Crypto/src/bcpg/Crc24.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/Crypto/src/bcpg/Crc24.cs b/Crypto/src/bcpg/Crc24.cs
new file mode 100644

index 000000000..97846f4fb --- /dev/null +++ b/Crypto/src/bcpg/Crc24.cs
@@ -0,0 +1,46 @@ +using System; + +namespace Org.BouncyCastle.Bcpg +{ + public class Crc24 + { + private const int Crc24Init = 0x0b704ce; + private const int Crc24Poly = 0x1864cfb; + + private int crc = Crc24Init; + + public Crc24() + { + } + + public void Update( + int b) + { + crc ^= b << 16; + for (int i = 0; i < 8; i++) + { + crc <<= 1; + if ((crc & 0x1000000) != 0) + { + crc ^= Crc24Poly; + } + } + } + + [Obsolete("Use 'Value' property instead")] + public int GetValue() + { + return crc; + } + + public int Value + { + get { return crc; } + } + + public void Reset() + { + crc = Crc24Init; + } + } +}