close

Trust Me!! Trust You!!


  • Blog
  • Local Log
  • Tag Cloud
  • Key Log
  • Guestbook
  • RSS Feed
  • Write a Post
  • Admin

혹시 블로그 스킨이 깨져 보이시나요? 최신버전의 Internet Explorer(Windows용), Opera, Firefox를 사용해보세요.

Found 2 article(s) for 'C#'.

  1. 2016/06/29 c# CRC32 checksum
  2. 2016/03/09 Datamatrix.net 이용 C# Data matrix barcode 생성

c# CRC32 checksum

App 프로그래밍
2016/06/29 15:28
 

using System.IO;
using System.Security.Cryptography;    


           Crc32 crc32 = new Crc32();
            String hash = String.Empty;
            using (FileStream fs = File.Open(@"c:\\J2060408462350.png", FileMode.Open)) //here you pass the file name
            {
                foreach (byte b in crc32.ComputeHash(fs))
                {
                    hash += b.ToString("x2").ToLower();
                }
                //Console.WriteLine("CRC-32 is {0}", hash);

                MessageBox.Show(hash);

            }
 


  public sealed class Crc32 : HashAlgorithm
    {
        public const UInt32 DefaultPolynomial = 0xedb88320u;
        public const UInt32 DefaultSeed = 0xffffffffu;

        static UInt32[] defaultTable;

        readonly UInt32 seed;
        readonly UInt32[] table;
        UInt32 hash;

        public Crc32()
            : this(DefaultPolynomial, DefaultSeed)
        {
        }

        public Crc32(UInt32 polynomial, UInt32 seed)
        {
            table = InitializeTable(polynomial);
            this.seed = hash = seed;
        }

        public override void Initialize()
        {
            hash = seed;
        }

        protected override void HashCore(byte[] array, int ibStart, int cbSize)
        {
            hash = CalculateHash(table, hash, array, ibStart, cbSize);
        }

        protected override byte[] HashFinal()
        {
            var hashBuffer = UInt32ToBigEndianBytes(~hash);
            HashValue = hashBuffer;
            return hashBuffer;
        }

        public override int HashSize { get { return 32; } }

        public static UInt32 Compute(byte[] buffer)
        {
            return Compute(DefaultSeed, buffer);
        }

        public static UInt32 Compute(UInt32 seed, byte[] buffer)
        {
            return Compute(DefaultPolynomial, seed, buffer);
        }

        public static UInt32 Compute(UInt32 polynomial, UInt32 seed, byte[] buffer)
        {
            return ~CalculateHash(InitializeTable(polynomial), seed, buffer, 0, buffer.Length);
        }

        static UInt32[] InitializeTable(UInt32 polynomial)
        {
            if (polynomial == DefaultPolynomial && defaultTable != null)
                return defaultTable;

            var createTable = new UInt32[256];
            for (var i = 0; i < 256; i++)
            {
                var entry = (UInt32)i;
                for (var j = 0; j < 8; j++)
                    if ((entry & 1) == 1)
                        entry = (entry >> 1) ^ polynomial;
                    else
                        entry = entry >> 1;
                createTable[i] = entry;
            }

            if (polynomial == DefaultPolynomial)
                defaultTable = createTable;

            return createTable;
        }

        static UInt32 CalculateHash(UInt32[] table, UInt32 seed, IList<byte> buffer, int start, int size)
        {
            var hash = seed;
            for (var i = start; i < start + size; i++)
                hash = (hash >> 8) ^ table[buffer[i] ^ hash & 0xff];
            return hash;
        }

        static byte[] UInt32ToBigEndianBytes(UInt32 uint32)
        {
            var result = BitConverter.GetBytes(uint32);

            if (BitConverter.IsLittleEndian)
                Array.Reverse(result);

            return result;
        }
    }

이올린에 북마크하기
TAG C#, CRC32
Trackback 210 / No comment.

Trackback Address :: http://viper150.cafe24.com/trackback/282

You can also say.

Datamatrix.net 이용 C# Data matrix barcode 생성

App 프로그래밍
2016/03/09 12:50
 

using DataMatrix.net;

        private static void TestMatrixEnCoder()
        {


            string fileName = @"c:\\gs1DataMatrix1.png";
            string gs1Code = "J2060408462350";
            DmtxImageEncoder encoder = new DmtxImageEncoder();
            DmtxImageEncoderOptions options = new DmtxImageEncoderOptions();
            options.ModuleSize = 2;
            options.MarginSize = 2;
            options.BackColor = Color.White;
            options.ForeColor = Color.Black;
            //options.Scheme = DmtxScheme.DmtxSchemeAsciiGS1;
            //options.Scheme = DmtxScheme.DmtxSchemeText;
            options.Scheme = DmtxScheme.DmtxSchemeAscii;
            Bitmap encodedBitmap = encoder.EncodeImage(gs1Code, options);
            //encodedBitmap.Save(fileName, ImageFormat.Png);
            encodedBitmap.Save(fileName);
           
        }

---------------------------------------------------------------------------
DataMatrix.net.dll

이올린에 북마크하기
TAG 2d, C#, DataMatrix, 바코드, 바코드 이미지 생성
One trackback was sent. / No comment.

Trackback Address :: http://viper150.cafe24.com/trackback/276

You can also say.

Prev 1 Next
블로그 이미지
이것저것 불펌금지도 퍼다가 담습니다. 외부에 비공개된 페이지 입니다. By. 어른왕자

카테고리

  • 전체 (298)
    • 사는 이야기 (115)
    • 웹 프로그래밍 (102)
    • App 프로그래밍 (22)
    • IT 뉴스&기타 (22)
    • 박한별 (4)
    • 역사&기타지식 (9)

태그목록

  • 개통이력
  • UTF-8
  • 실험
  • 비사
  • kbs
  • 귀여움
  • java doc
  • 착각
  • 한글컨트롤
  • svn
  • 아이유착각
  • 수원
  • DB2
  • 초경합금
  • 부부관계
  • 획갈림
  • 로딩중
  • 몰카
  • Calendar
  • Ajax
  • 한예슬
  • 김혜수
  • IU
  • 서비스
  • RISS
  • java api
  • uTorrent
  • 윈도우7
  • 2d
  • 동적추가

최근에 올라온 글

  • 보험사의 조정신청 대응방법.
  • 어느 천재의 앞선 시선.
  • [병맛더빙] 누구게..... (1)
  • 韓경제 `회색 코뿔소` 상황...
  • SVN Connector 설치 URL.
  • 군대를 가지 않는 서울대생.
  • “운은 하늘의 귀여움 받는...
  • 목장에서 알바하다가 캐스...
  • [펌]믿고 거르는 관상.
  • 하루에 1세트씩 하면 좋다...

최근에 달린 댓글

  • 여성흥분제팝니다 24시간 전... 정력제 04/18
  • 유벤투스의 스타 공격수, 크리... 호날두 04/18
  • 저도 칭구덕에 이젠 큰 부자가... 가현 04/15
  • 저도 칭구덕에 이젠 큰 부자가... 가현 04/12
  • 배우 김정현은 길지 않은 연기... 김정현 04/10

최근에 받은 트랙백

  • Solace Salts Bold Tobacco. Solace Salts Bold Tobacco 03/29
  • read this post from Bookie 7. read this post from Bookie 7 02/28
  • công ty may đồng phục. công ty may đồng phục 01/08
  • Israelnightclub`s recent blo... Israelnightclub`s recent blo.. 01/06
  • Suggested Browsing. Suggested Browsing 01/06

글 보관함

  • 2019/03 (1)
  • 2018/12 (1)
  • 2018/09 (1)
  • 2018/08 (1)
  • 2018/02 (1)

달력

«   2021/04   »
일 월 화 수 목 금 토
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  

링크

  • Total : 265866
  • Today : 25
  • Yesterday : 41
Tattertools
Eolin
rss

어른왕자's blog is powered byTattertools1.1.2.2 : Animato